-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: LINQ3
-
None
There are many scenarios. The basic ones are:
F.All(predicate) => { F : { $not : { $elemMatch : { $not : <predicate> } } } }
F.Any() => { F : { $ne : null, $not : { $size : 0 } } }
F.Any(predicate) => { F : { $elemMatch : <predicate> } }
The following are special cases that translate to $in or $all:
a.All(i => F.Contains(i)) => { F : { $all : [<a>] } }
a.Any(i => F.Contains(i)) => { F : { $in : [<a>] } }
F.Any(i => a.Contains(i)) => { F : { $in : [<a>] } }
// where a is an array constant and F is an array field
All or Any may also be preceded by a Where:
F.Where(p1).All(p2) => { F : { $not : { $elemMatch : { $not : <p1 && p2> } } } } F.Where(p1).Any() => { F : { $elemMatch : <p1> } } F.Where(p2).Any(p2) => { F : { $elemMatch : <p1 && p2> } }
All or Any may also be preceded by an OfType:
F.OfType<T>().All(p) => { F : { $not : { $elemMatch : { $not : { $and : [{ _t : <disc> }, <p>] } } } } } F.OfType<T>().Any() => { F : { $elemMatch : { _t : <disc> } } } F.OfType<T>().Any(p) => { F : { $elemMatch : { $and : [{ _t : <disc> }, <p>] } } }
And finally, Where and OfType may both be used, possibly multiple times, in which case there are more than two predicates and the above generalizes to combine all the predicates.
- is depended on by
-
CSHARP-3473 LINQ3: Get PredicateTranslatorTests to pass
- Closed
- related to
-
CSHARP-4558 Support IEnumerable.OfType<>() in find() projections
- Closed