The following setting is correct:
I want to get a collection containing A, B, C and X (ABX and ACX) I want to filter the collection so that only those elements that have X.EndDate = Date are X.EndDate = Date .
I do not want the elements of X not to pass these criteria. Can this be done in one Select?
I am currently trying to use the following code:
var set = _context.Set<A>() .Include("BX") .Include("CX") .Where(a => aBAny(b => bXAny(x => x.EndDate == date)) || aCAny(c => cXAny(x => x.EndDate == date))) .ToList();
However, when the BX is within the filter criteria, it will also include CX. And when one of the BX (X may be many) is true to the criteria, it will return all BX entities
I tried my best to give an example:
ABX X.EndDate A1 B1 BX1 2015-01-01 A1 B1 BX2 2015-01-02 A1 B2 BX3 2015-01-09 ACX X.EndDate A1 C1 CX1 2015-01-03 A1 C1 CX2 2015-01-03 A1 C2 CX3 2015-01-02 When date == 2015-01-02 Results are: A1 B1 BX1 BX2 B2 BX3 C1 CX1 CX2 C2 CX3 Desired results are: A1 B1 BX2 C2 CX2
Note. I can only use this notation, and not as an SQL-like notation. There are more objects that need to be included, and this can (apparently) only be done using .Include ("") with quotes
source share