Linq to SQL Select in saved Proc version
I have a stored procedure called via LINQ to SQL, the memorized procedure calls another stored proc inside it and has a SELECT to output the result. the SELECT result is not going back to my LINQ to SQL, I can only get the int result value. How can I get the result of selecting a stored proc s inside a proc stored procedure
a source to share
The LINQ designer cannot accurately parse your stored procedure to define the schema. One job is to temporarily change the stored proc to just pick the right schema. Redesign it in the designer. Then change the saved proc back to original. This way the designer can calculate the schema and map it correctly to the correct object.
a source to share
When you call a stored procedure from Sql Server Management Studio, does it return multiple rowsets?
If this case, using a stored procedure from LINQ, is not trivial, see this article .
Reading multiple results is easy with the NextResult method from the DataReader:
var com = yourConnection.CreateCommand();
com.CommandText = "execute dbo.YourSp 'par1'";
var read = com.ExecuteReader();
// Move to second result set and read it
read.NextResult();
while (read.Read()) {
Console.WriteLine(read["MyField"]);
}
a source to share