Query Expression Syntax for Standard Query Operators
Some of the more frequently used standard query operators have dedicated C# and 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. The C# and Visual Basic programming languages do not provide dedicated query expression syntax for the same methods. The table lists the syntax for both of these languages.
Method |
C# Query Expression Syntax |
Visual Basic Query Expression Syntax |
---|---|---|
not applicable |
Aggregate … In … Into All(…) (For more information, see Aggregate Clause (Visual Basic).) |
|
not applicable |
Aggregate … In … Into Any() (For more information, see Aggregate Clause (Visual Basic).) |
|
not applicable |
Aggregate … In … Into Average() (For more information, see Aggregate Clause (Visual Basic).) |
|
Use an explicitly typed range variable, for example: from int i in numbers (For more information, see from clause (C# Reference).) |
From … As … (For more information, see From Clause (Visual Basic).) |
|
not applicable |
Aggregate … In … Into Count() (For more information, see Aggregate Clause (Visual Basic).) |
|
not applicable |
Distinct (For more information, see Distinct Clause (Visual Basic).) |
|
group … by -or- group … by … into … (For more information, see group clause (C# Reference).) |
Group … By … Into … (For more information, see Group By Clause (Visual Basic).) |
|
join … in … on … equals … into … (For more information, see join clause (C# Reference).) |
Group Join … In … On … (For more information, see Group Join Clause (Visual Basic).) |
|
join … in … on … equals … (For more information, see join clause (C# Reference).) |
From x In …, y In … Where x.a = b.a -or- Join … [As …]In … On … (For more information, see Join Clause (Visual Basic).) |
|
not applicable |
Aggregate … In … Into LongCount() (For more information, see Aggregate Clause (Visual Basic).) |
|
not applicable |
Aggregate … In … Into Max() (For more information, see Aggregate Clause (Visual Basic).) |
|
not applicable |
Aggregate … In … Into Min() (For more information, see Aggregate Clause (Visual Basic).) |
|
OrderBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>) |
orderby (For more information, see orderby clause (C# Reference).) |
Order By (For more information, see Order By Clause (Visual Basic).) |
OrderByDescending<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>) |
orderby … descending (For more information, see orderby clause (C# Reference).) |
Order By … Descending (For more information, see Order By Clause (Visual Basic).) |
select (For more information, see select clause (C# Reference).) |
Select (For more information, see Select Clause (Visual Basic).) |
|
Multiple from clauses. (For more information, see from clause (C# Reference).) |
Multiple From clauses (For more information, see From Clause (Visual Basic).) |
|
not applicable |
Skip (For more information, see Skip Clause (Visual Basic).) |
|
not applicable |
Skip While (For more information, see Skip While Clause (Visual Basic).) |
|
not applicable |
Aggregate … In … Into Sum() (For more information, see Aggregate Clause (Visual Basic).) |
|
not applicable |
Take (For more information, see Take Clause (Visual Basic).) |
|
not applicable |
Take While (For more information, see Take While Clause (Visual Basic).) |
|
ThenBy<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>) |
orderby …, … (For more information, see orderby clause (C# Reference).) |
Order By …, … (For more information, see Order By Clause (Visual Basic).) |
ThenByDescending<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>) |
orderby …, … descending (For more information, see orderby clause (C# Reference).) |
Order By …, … Descending (For more information, see Order By Clause (Visual Basic).) |
where (For more information, see where clause (C# Reference).) |
Where (For more information, see Where Clause (Visual Basic).) |
See Also
Concepts
Standard Query Operators Overview
Classification of Standard Query Operators by Manner of Execution