Linq 存储过程不会也不应该返回任何错误结果

Linq 存储过程不会也不应该返回任何错误结果,linq,stored-procedures,Linq,Stored Procedures,我有一个存储过程,我们使用它简单地将新记录插入到各个表中。此存储过程设置为不返回任何仅用于执行的内容。当我将它拉入DBML时,它将它设置为“Void”,我认为这是正确的。下面是从DMBL自动生成的代码 [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.sp_PTS_Action_Insert_Comment")] public void sp_PTS_Action_Insert_Comment([globa

我有一个存储过程,我们使用它简单地将新记录插入到各个表中。此存储过程设置为不返回任何仅用于执行的内容。当我将它拉入DBML时,它将它设置为“Void”,我认为这是正确的。下面是从DMBL自动生成的代码

[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.sp_PTS_Action_Insert_Comment")]
        public void sp_PTS_Action_Insert_Comment([global::System.Data.Linq.Mapping.ParameterAttribute(Name="Form_Name", DbType="VarChar(20)")] string form_Name, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Form_Number", DbType="VarChar(25)")] string form_Number, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="UID", DbType="VarChar(15)")] string uID, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Cmt", DbType="VarChar(200)")] string cmt)
        {
            this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), form_Name, form_Number, uID, cmt);
        }
    }
我将此SP称为以下SP:

_context.sp_PTS_Action_Insert_Comment(formInformation["formType"], formInformation["formNumber"], userId, comment);
当这个代码执行时,它抛出一个错误

“系统无效不是有效的返回类型 用于映射存储过程“


我的问题是,您是否可以使用linq to存储过程和有意不返回任何内容的SP?如果是这样的话,在这个例子中我做错了什么?

我不确定为什么在放置一个不返回任何内容的过程时,Linq会构建上面的void函数,因为它会抛出“nota valid return type”错误

为了解决这个问题,我在过程中添加了一个返回,使用SCOPE_IDENTITY()作为返回,这样我也可以在代码中使用它

希望有帮助。

相关帖子。