I have a DbContext application where I need to use ObjectContext on a certain form (data binding issue with DbContext). I tried accessing the ObjectContext entities using
var oc = ((IObjectContextAdapter)MyEntities).ObjectContext;
but entities do not show up when typing oc.Students
. What shall I do to have access to entities?
I believe you're looking for the method CreateObjectSet<TEntity>()
In your scenario, that would be used like so
var oc = ((IObjectContextAdapter)MyEntities).ObjectContext;
var query = oc.CreateObjectSet<Student>();
You can then use LINQ to build your query
much the same way you would with an IQueryable<Student>
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.