标准查询运算符的查询表达式语法 (Visual Basic)

某些使用更频繁的标准查询运算符具有专用的 Visual Basic 语言关键字语法,使用该语法可以在查询表达式中调用这些运算符。 查询表达式是比基于方法的等效项更具可读性的另一种查询表示形式。 查询表达式子句在编译时被转换为对查询方法的调用。

查询表达式语法表

下表列出包含等效查询表达式子句的标准查询运算符。

方法 Visual Basic 查询表达式语法
All Aggregate … In … Into All(…)

(有关详细信息,请参阅 Aggregate 子句。)
Any Aggregate … In … Into Any()

(有关详细信息,请参阅 Aggregate 子句。)
Average Aggregate … In … Into Average()

(有关详细信息,请参阅 Aggregate 子句。)
Cast From … As …

(有关详细信息,请参阅 From 子句。)
Count Aggregate … In … Into Count()

(有关详细信息,请参阅 Aggregate 子句。)
Distinct<TSource>(IEnumerable<TSource>) Distinct

(有关详细信息,请参阅 Distinct 子句。)
GroupBy Group … By … Into …

(有关详细信息,请参阅 Group By 子句。)
GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>) Group Join … In … On …

(有关详细信息,请参阅 Group Join 子句。)
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

-或-

Join … [As …]In … On …

(有关详细信息,请参阅 Join 子句。)
LongCount Aggregate … In … Into LongCount()

(有关详细信息,请参阅 Aggregate 子句。)
Max Aggregate … In … Into Max()

(有关详细信息,请参阅 Aggregate 子句。)
Min Aggregate … In … Into Min()

(有关详细信息,请参阅 Aggregate 子句。)
OrderBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>) Order By

(有关详细信息,请参阅 Order By 子句。)
OrderByDescending<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>) Order By … Descending

(有关详细信息,请参阅 Order By 子句。)
Select Select

(有关详细信息,请参阅 Select 子句。)
SelectMany 多个 From 子句

(有关详细信息,请参阅 From 子句。)
Skip Skip

(有关详细信息,请参阅 Skip 子句。)
SkipWhile Skip While

(有关详细信息,请参阅 Skip While 子句。)
Sum Aggregate … In … Into Sum()

(有关详细信息,请参阅 Aggregate 子句。)
Take Take

(有关详细信息,请参阅 Take 子句。)
TakeWhile Take While

(有关详细信息,请参阅 Take While 子句。)
ThenBy<TSource,TKey>(IOrderedEnumerable<TSource>, Func<TSource,TKey>) Order By …, …

(有关详细信息,请参阅 Order By 子句。)
ThenByDescending<TSource,TKey>(IOrderedEnumerable<TSource>, Func<TSource,TKey>) Order By …, … Descending

(有关详细信息,请参阅 Order By 子句。)
Where Where

(有关详细信息,请参阅 Where 子句。)

另请参阅