【发布时间】:2011-06-23 07:10:56
【问题描述】:
我的存储过程使用一个输出参数。我想在我的 MVC 应用程序中使用该参数。 我可以知道如何在 LINQ 中使用 out 参数吗? 我在做什么
[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.Usp_Insert_Id")]
public int Usp_Insert_Id(
[global::System.Data.Linq.Mapping.ParameterAttribute(Name="EmpID", DbType="Int")]
System.Nullable<int> EmpID)
{
IExecuteResult result =
this.ExecuteMethodCall(
this,
((MethodInfo)(MethodInfo.GetCurrentMethod())),
EmpID);
return ((int)(result.ReturnValue));
}
在我正在使用的控制器中
int output = 0;
output = dataContext.Usp_Insert_Id(Id,ref output);
我的存储过程是
create procedure Usp_Insert_Id ( @Id
int, @Return int out ) as insert into
Emplyee(ID,Date_TIME,Status)
values (@Id,GETDATE(),1)
select @Return=SCOPE_IDENTITY()
告诉我我做错了什么?
【问题讨论】:
标签: c# stored-procedures linq-to-sql