- Sales orders of the customers who locate in
New York - Nesting subquery
- Subquery in place of an expression
INoperatorANYoperatorALLoperator- Customers who bought products in 2017
- Customers who did not buy any products in 2017
FROMclause
When subquery
SELECTsa single column (or a tuple), we may return itAsCollection()orAsSingle(). The correct type propagates out. Thus the return type ofSubQuery()method above isICollection<int?>.
For clarity let's assign the result of the subquery to a local variable (of course the produced SQL is same in either case):
In fact we already covered IN operator in the very first example above.
Just replace ANY with ALL above and run!
ELINQ maps SQL's EXISTS operator to Any():
Since ELINQ supports variables, this very powerfull feature does not lead to complex nesting.