I'm migrating my project from ObjectContext to DbContext and I have a problem with this sentence:
var query = db.Inventory.Where("it.IdState in {" + states + "}");
This works with ObjectContext but now I get an error at compilation time:
Error CS1503 Argument 2: cannot convert from 'string' to 'System.Linq.Expressions.Expression<System.Func<Test.DAL.Inventory, bool>>'
Seems not to be posible to do this now, I tryied to expose ObjectContext to do it, but I couldn't find the way
Any idea? Thank!
You can (and should) strongly type these arguments as an expression.
var query = db.Inventory.Where(x => states.Contains(x.IdState));
You kind of need to reverse it
var query = db.Inventory.Where(it => states.Contains(it.IdState));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With