Query Expression Syntax for Standard Query Operators (Visual Basic)

Some of the more frequently used standard query operators have dedicated Visual Basic language keyword syntax that enables them to be called as part of a query expression. A query expression is a different, more readable form of expressing a query than its method-based equivalent. Query expression clauses are translated into calls to the query methods at compile time.

Query Expression Syntax Table

The following table lists the standard query operators that have equivalent query expression clauses.

Method Visual Basic Query Expression Syntax
All Aggregate … In … Into All(…)

(For more information, see Aggregate Clause.)
Any Aggregate … In … Into Any()

(For more information, see Aggregate Clause.)
Average Aggregate … In … Into Average()

(For more information, see Aggregate Clause.)
Cast From … As …

(For more information, see From Clause.)
Count Aggregate … In … Into Count()

(For more information, see Aggregate Clause.)
Distinct<TSource>(IEnumerable<TSource>) Distinct

(For more information, see Distinct Clause.)
GroupBy Group … By … Into …

(For more information, see Group By Clause.)
GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>) Group Join … In … On …

(For more information, see Group Join Clause.)
Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>) From x In …, y In … Where x.a = b.a

-or-

Join … [As …]In … On …

(For more information, see Join Clause.)
LongCount Aggregate … In … Into LongCount()

(For more information, see Aggregate Clause.)
Max Aggregate … In … Into Max()

(For more information, see Aggregate Clause.)
Min Aggregate … In … Into Min()

(For more information, see Aggregate Clause.)
OrderBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>) Order By

(For more information, see Order By Clause.)
OrderByDescending<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>) Order By … Descending

(For more information, see Order By Clause.)
Select Select

(For more information, see Select Clause.)
SelectMany Multiple From clauses

(For more information, see From Clause.)
Skip Skip

(For more information, see Skip Clause.)
SkipWhile Skip While

(For more information, see Skip While Clause.)
Sum Aggregate … In … Into Sum()

(For more information, see Aggregate Clause.)
Take Take

(For more information, see Take Clause.)
TakeWhile Take While

(For more information, see Take While Clause.)
ThenBy<TSource,TKey>(IOrderedEnumerable<TSource>, Func<TSource,TKey>) Order By …, …

(For more information, see Order By Clause.)
ThenByDescending<TSource,TKey>(IOrderedEnumerable<TSource>, Func<TSource,TKey>) Order By …, … Descending

(For more information, see Order By Clause.)
Where Where

(For more information, see Where Clause.)

See also