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

public int Usp_Insert_Id(
[global::System.Data.Linq.Mapping.ParameterAttribute(Name="EmpID", DbType="Int")]
System.Nullable<int> EmpID)
IExecuteResult result =
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
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