我正在使用以下方法
public static ObjectQuery<T> ObjectQueryListQuery<T>(ObjectContext context, string sql)
{
var context1 = new NorthwindEntities1();
// sql =;
var x = (IObjectContextAdapter) context1;
// x.ObjectContext.CreateQuery<>()
ObjectQuery<T> t1;
t1 = new ObjectQuery<T>(sql, x.ObjectContext);
// var customersQuery = t1.ToList();
var vvv = t1.ToList();
string[] columns = new string[2];
columns[0] = "ProductName";
columns[1] = "ProductID";
foreach (var t1itm in t1)
{
foreach (var column in columns)
{
var tp = t1itm.GetType();
var px = tp.GetProperty(column);
var val = px.GetValue(t1itm, null);
Console.WriteLine(val);
Console.ReadKey();
}
}
return t1;
我正在调用这个函数
var tq= ObjectQueryListQuery<Product>(p.ObjectContext, "SELECT VALUE p FROM NorthwindEntities1.Products AS p ");
有没有办法删除一些通用的东西,比如<Dbset>
. 我们曾经在 EF5 中执行此 EF4,但我无法做到这一点