【问题标题】:How to use OUT Parameters in LINQ如何在 LINQ 中使用 OUT 参数
【发布时间】: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


    【解决方案1】:

    【讨论】:

    • 请检查我更新的问题??请告诉我我做错了什么?
    • 方法或操作没有实现。
    • 嘿嘿跟着scottgu的文章一步一步检查一遍
    • 首先删除该程序...然后尝试
    • 我没有得到所需的结果,现在我为此创建了新的存储过程。请检查我哪里错了?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    • 2013-01-05
    • 2015-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多