Reputation: 527
My stored procedure use one out parameters. I want to use that out parameters in My MVC application. Can I know how can I use out parameters in LINQ. What I am doing
[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));
}
in the controller I’m using
int output = 0;
output = dataContext.Usp_Insert_Id(Id,ref output);
My Stored Procedure for this is
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()
tell me what I’m doing wrong?
Upvotes: 5
Views: 7858
Reputation: 176936
Check good article by ScottGU
LINQ to SQL (Part 6 - Retrieving Data Using Stored Procedures)
Ans for you :
LINQ and StoredProcedure output Parameter
Upvotes: 3