How LinqToSql Generates Stored Procedure Output

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

sp_testResult

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

+3


source to share


1 answer


That's what's going on in SqlCommandBuilder.GetSchemaTable(...)

, which, unfortunately, is protected

.

SqlCommand command; // setup as SP

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

      



The result DataTable

will contain the output schema.

If I remember correctly, you don't need to pass parameters for this to work.

+3


source







All Articles