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

C# 相当于(Linq to Entity)中(Linq to Sql)的GetCommand()函数,c#,asp.net,linq,entity-framework,linq-to-entities,C#,Asp.net,Linq,Entity Framework,Linq To Entities,我有一个为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.

我有一个为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。我正在使用ObjectContextq是System.Linq.IQueryable。因此,尽管有dc.GetCommand(q).CommandText。我应该用我知道的。对于DbParameter,情况也类似。非常感谢您的帮助。

EF没有与
GetCommand
等效的命令。如果您想访问参数,请尝试使用(检查样本以进行跟踪)