I want to return records where the date column is greater than
DateTime.Now.AddDays(-3), but only if the type column is complete.
Meaning, I want to return everything except for records that are older than 3 days and the type is == complete (Enum 1).
It's almost as if I need Except, but for that, I'd need to enumerate the results, then I wouldn't have my page number of results (.Take(10)).
How would this be done in linq? I can't figure out how this query would look. I would like the query to be done SQL SERVER side as much as possible as to be efficient.
Just to be clear - I want all results, EXCEPT records that are completed and older than 3 days.
(completed meaning the type column value == 1 (Enum))
My project is .NetCore 3.1
Could be this that you need ?
Var results = context.Entity.Where(x=> x.Type != enum.Completed ||( x.Type == enum.Completed && x.Date >=DateTime.Now.AddDays(-3)));
Maybe something like this?
Results = context.Entity.Where(x => x.Date > DateTime.Now.AddDays(-3) || x.Type != YourEnum.Complete);