How LinqToSql Generates output result of stored procedures

106 views Asked by At

for example you have a stored procedure with title : sp_test when you drag into LinqToSql, it generates sp_testResult class with stored procedure output columns as its properties.

I want to know how LinqToSql distinguish output result of stored procedure?

1

There are 1 answers

0
leppie On BEST ANSWER

Here is what happens in SqlCommandBuilder.GetSchemaTable(...) which is sadly protected.

SqlCommand command; // setup as SP

using (SqlDataReader reader = command.ExecuteReader(
             CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
{
  return reader.GetSchemaTable();
}

The resultant DataTable will contain the output schema.

If I remember correctly, you do not have to pass parameters for this work.