我创建了一个带有一些参数的存储过程。这些是我的程序的参数:
ALTER Procedure [dbo].[SaveInvitation]
(
@InvitationID INT OUTPUT,
@UserID INT,
@Email NCHAR(100),
@InvitationGUID UNIQUEIDENTIFIER OUTPUT
)
AS
我的function.cs
:
public SaveInvitation_Result SaveInvitation(int userID,string email)
{
SaveInvitation_Result result = null;
var results = this.DataContext.SaveInvitation(null,userID,email,null);
if (results != null)
{
result = results.FirstOrDefault();
}
return result;
}
我将一些参数传递给我的函数SaveInvitation
,如下所示:
我的DataBaseModel.Designer.cs
:
public ObjectResult<SaveInvitation_Result> SaveInvitation(ObjectParameter invitationID, Nullable<global::System.Int32> userID, global::System.String email, ObjectParameter invitationGUID)
{
ObjectParameter userIDParameter;
if (userID.HasValue)
{
userIDParameter = new ObjectParameter("UserID", userID);
}
else
{
userIDParameter = new ObjectParameter("UserID", typeof(global::System.Int32));
}
ObjectParameter emailParameter;
if (email != null)
{
emailParameter = new ObjectParameter("Email", email);
}
else
{
emailParameter = new ObjectParameter("Email", typeof(global::System.String));
}
return base.ExecuteFunction<SaveInvitation_Result>("SaveInvitation", invitationID, userIDParameter, emailParameter, invitationGUID);
}
当我执行这个函数/程序时,我得到一个异常
参数数组中索引 0 处的参数为空。
如何将值传递给invitationID
and invitationGUID
?