简体   繁体   中英

Equivalent of GetCommand() function of (Linq to Sql) in (Linq to Entity)

I have a generic function written for 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. I am using ObjectContext. q is System.Linq.IQueryable . So inspite of dc.GetCommand(q).CommandText . What should I use know. And similarly for DbParameter . Any help is appreciated.

EF doesn't have equivalent to GetCommand . If you want to have access to parameters try to use EF Provider Wrapper (check sample for Tracing).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM