【问题标题】:Equivalent of GetCommand() function of (Linq to Sql) in (Linq to Entity)(Linq to Sql) 中的 (Linq to Sql) 的 GetCommand() 函数等价于 (Linq to Entity)
【发布时间】:2011-11-14 09:31:08
【问题描述】:

我有一个为 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 也是如此。任何帮助表示赞赏。

【问题讨论】:

    标签: c# asp.net linq entity-framework linq-to-entities


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      • 2010-12-18
      • 1970-01-01
      相关资源
      最近更新 更多