In EF core I have a list of composite Id's, and I then want to have of those ids from the database.
var crits = new List<MyCrit>()
{
new MyCrit() {Key1 = "A", Key2 = 3},
new MyCrit() {Key1 = "B", Key2 = 4}
};
it should end up with SQL like this:
select * from MyTable where (Key1="A" and Key2 = 3) or (Key1="B" and Key2 = 4)
I have configured the table to have correct setup, but I cannot get the OR.
Here is my code:
var query = _db.MyTable.AsQueryable();
foreach (var crit in crits)
{
query = query.Where(m => m.Key1 == crit.Key1 && m.Key2 == crit.Key2);
}
Unfortunatly that gives me this SQL:
select * from MyTable where (Key1="A" and Key2 = 3) and (Key1="B" and Key2 = 4)
I can't figure out how to add inside the loop so it becomes OR.