Query Entity Framework 4
Is it possible to run a query on an EF4.0 data context and get all objects of a certain type?
Say the context has books, genres & authors but I only have a generic parameter, t. Is it possible to get all of type just by using this t?
I don't thi开发者_如何学Cnk it is :(
 var x = from z in context.CreateObjectSet<Person>()
                    select z;
I believe this will do the trick.
ObjectSet<T> set = (ObjectSet<T>)context.GetType().GetProperties().FirstOrDefault(p => p.PropertyType.IsGenericType &&
                p.PropertyType.GetGenericTypeDefinition() == typeof(ObjectSet<T>)).GetValue(this, null);
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论