What did the generated linq-to-sql code look like? Perhaps you manually changed it to return void?
Creating a stored procedure that does not produce output like this:
CREATE PROCEDURE MyProc AS BEGIN IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'DropMe') DROP TABLE DropMe END GO
should generate the following code when adding it to the l2s design surface -
[Function(Name = "dbo.MyProc")] public int MyProc() { IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod()))); return ((int)(result.ReturnValue)); }
If you return void instead, it will cause it to throw this exception.
So, if I change the above to this -
[Function(Name = "dbo.MyProc")] public void MyProc() { IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod()))); return; }
He will throw it on a call -
Line 17: public void MyProc () Line 18: {Line 19: IExecuteResult result = this.ExecuteMethodCall (this, ((MethodInfo) (MethodInfo.GetCurrentMethod ()))); Line 20: return; // ((INT) (result.ReturnValue)); Line 21:}
Source file: C: \ Build \ blah.cs Line: 19
Stack trace:
[InvalidOperationException: "System.Void" is not a valid return type for the displayed stored procedure method.]
System.Data.Linq.SqlClient.QueryConverter.TranslateStoredProcedureCall (MethodCallExpression mce, MetaFunction function) +904265
source share