Question

I would like to use the "Query Builder Methods" on my DbContext like following:

using (var context = new MyDbContext())
{
    var query = context.MyEntities.Where("Id = @id", new ObjectParameter("id", 1));
}

But it cannot resolve this specific overload of Where. What am I missing here?

Was it helpful?

Solution

Using this solved my problem:

var objectContext = ((IObjectContextAdapter) context).ObjectContext;
var query = objectContext.CreateObjectSet<MyEntities>().Where("it.Id = @id", new ObjectParameter("id", 1));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top