[英]Equivalent of GetCommand() function of (Linq to Sql) in (Linq to Entity)
I have a generic function written for Linq to Sql.我有一个为 Linq to Sql 编写的通用函数。
Some code is:一些代码是:
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));
}
}
where dc is a DataContext.其中 dc 是一个 DataContext。 I am using ObjectContext.
我正在使用 ObjectContext。 q is System.Linq.IQueryable .
q 是 System.Linq.IQueryable 。 So inspite of dc.GetCommand(q).CommandText .
所以尽管 dc.GetCommand(q).CommandText 。 What should I use know.
我应该用什么知道。 And similarly for DbParameter .
与DbParameter类似。 Any help is appreciated.
任何帮助表示赞赏。
EF doesn't have equivalent to GetCommand
. EF 没有等效于
GetCommand
。 If you want to have access to parameters try to use EF Provider Wrapper (check sample for Tracing).如果您想访问参数,请尝试使用EF Provider Wrapper (检查示例以获取跟踪)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.