5

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?

0

1 Answer 1

3

Check good article by ScottGU enter image description here

enter image description here

LINQ to SQL (Part 6 - Retrieving Data Using Stored Procedures)

Ans for you :

LINQ and StoredProcedure output Parameter

6
  • Please check the question i have updated?? Please tell me what i m doing wrong?
    – Saloni
    Jun 23, 2011 at 7:33
  • The method or operation is not implemented.
    – Saloni
    Jun 23, 2011 at 7:52
  • hey follow the scottgu article step by step and check again Jun 23, 2011 at 7:53
  • first of all remove that procedure... and than try Jun 23, 2011 at 7:53
  • i m not getting the required result now i have create new stored procedure for this. Please check where i m wrong?
    – Saloni
    Jun 23, 2011 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.