LinqToSql如何生成存储过程的输出结果

时间:2015-06-09 12:09:23

标签: .net linq stored-procedures linq-to-sql

例如,您有一个标题为 sp_test 的存储过程 当您拖入 LinqToSql 时,它会生成 sp_testResult 类,并将存储过程输出列作为其属性。

我想知道 LinqToSql 如何区分存储过程的输出结果?

1 个答案:

答案 0 :(得分:3)

以下是SqlCommandBuilder.GetSchemaTable(...)中发生的事情,遗憾的是protected

SqlCommand command; // setup as SP

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

结果DataTable将包含输出模式。

如果我没记错的话,你不必为这项工作传递参数。