Saloni Saloni -4 years ago 118
C# Question

How to use OUT Parameters in LINQ

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?

Answer Source
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download