Good afternoon, I'm doing an application in C # .Net Core, using lambda for database context handling. I have one question, which is as follows: I have a list of objects with these two attributes: Name and StartDate. Something like:
List<Operations> operations = new List<Operations>();
operations.Add(new Operation() { Name: "Exemplo 1", StartDate: "2018-07-02 00:00:00" };
operations.Add(new Operation() { Name: "Exemplo 2", StartDate: "2017-05-01 13:00:00" };
Now I would like to make a lambda in my context, iterating this list with a condition with the "OR" operator. Something that would look like this in SQL:
SELECT
*
FROM
contact t
WHERE
(t.OperationName = "Exemplo 1" AND t.ContactDate > "2018-07-02 00:00:00")
OR (t.OperationName = "Exemplo 1" AND t.ContactDate > "2017-05-01 13:00:00")
But I can not. The conditions within the parentheses are separated by AND, when they refer to the same object, and separating the objects by OR. I'm using Lambda, something like this:
dbContext.Teste.Where(x => x...);
@EDIT: A Fiddle I did to demonstrate my problem: link
In that Fiddle, I can only do the where with the first obj of operations, but I need to iterate through all objects. Anyone have any ideas how to do this using Lambda?