相当于(Linq to Entity)中(Linq to Sql)的GetCommand()函数

本文关键字:Linq to GetCommand 函数 Entity 相当于 Sql | 更新日期: 2023-09-27 18:14:46

我有一个为Linq to Sql编写的泛型函数。

有些代码是:

string sqlCmd = dc.GetCommand(q).CommandText;
{
   foreach (System.Data.Common.DbParameter dbp in dc.GetCommand(q).Parameters)
   {
      cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter(dbp.ParameterName, dbp.Value));
   }
}

,其中dc为DataContext。我正在使用ObjectContext。q是System.Linq.IQueryable。所以尽管dc.GetCommand(q). commandtext 。我应该用什么?对于DbParameter也是类似的。

相当于(Linq to Entity)中(Linq to Sql)的GetCommand()函数

EF不等于GetCommand。如果您想要访问参数,请尝试使用EF Provider Wrapper(检查跟踪示例)。