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 a SQL query something 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);
}
Unfortunately, that results in this SQL statement:
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.