EF5实体Sql dbset

时间:2013-01-09 11:25:52

标签: .net entity-framework visual-studio-2012

我正在使用以下方法

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我无法实现这个

0 个答案:

没有答案