支持和不支持的 LINQ 方法 (LINQ to Entities)
本节提供有关 LINQ to Entities 查询中支持和不支持的语言集成查询 (LINQ) 标准查询运算符的信息。 许多 LINQ 标准查询运算符都有可接受整数自变量的重载版本。 该整数参数对应于正在操作的序列中从零开始的索引,IEqualityComparer<T> 或 IComparer<T>。 除非专门指定,否则这些 LINQ 标准查询运算符的重载版本并不受支持,尝试使用它们将引发异常。
投影和限制方法
除了那些接受位置自变量的方法,LINQ to Entities 查询支持大多数 LINQ 投影和限制方法。 有关更多信息,请参阅 LINQ to Entities 查询中的标准查询运算符。 下表列出了支持的和不支持的投影和限制方法。
方法 | 支持 | Visual Basic 函数签名 | C# 方法签名 |
---|---|---|---|
Select | 支持 | Function Select(Of TSource, TResult) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, TResult)) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> Select<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector ) |
Select | 不支持 | Function Select(Of TSource, TResult) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Integer, TResult)) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> Select<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, int, TResult>> selector ) |
SelectMany | 支持 | Function SelectMany(Of TSource, TResult) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, IEnumerable(Of TResult))) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> SelectMany<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector ) |
SelectMany | 不支持 | Function SelectMany(Of TSource, TResult) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Integer, IEnumerable(Of TResult))) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> SelectMany<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector ) |
SelectMany | 支持 | Function SelectMany(Of TSource, TCollection, TResult) ( _ source As IQueryable(Of TSource), _ collectionSelector As Expression(Of Func(Of TSource, IEnumerable(Of TCollection))), _ resultSelector As Expression(Of Func(Of TSource, TCollection, TResult)) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> SelectMany\<TSource, TCollection, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func\<TSource, TCollection, TResult>> resultSelector ) |
SelectMany | 不支持 | Function SelectMany(Of TSource, TCollection, TResult) ( _ source As IQueryable(Of TSource), _ collectionSelector As Expression(Of Func(Of TSource, Integer, IEnumerable(Of TCollection))), _ resultSelector As Expression(Of Func(Of TSource, TCollection, TResult)) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> SelectMany\<TSource, TCollection, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, int, IEnumerable<TCollection>>> collectionSelector, Expression<Func\<TSource, TCollection, TResult>> resultSelector ) |
Where | 支持 | Function Where(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Where<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
Where | 不支持 | Function Where(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Integer, Boolean)) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Where<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, int, bool>> predicate ) |
联接方法
LINQ to Entities 支持大多数 LINQ 联接方法,但不支持接受 IEqualityComparer
的联接方法,原因是比较器不能转换为数据源。 有关更多信息,请参阅 LINQ to Entities 查询中的标准查询运算符。 下表列出了支持的和不支持的联接方法。
方法 | 支持 | Visual Basic 函数签名 | C# 方法签名 |
---|---|---|---|
GroupJoin | 支持 | Function GroupJoin(Of TOuter, TInner, TKey, TResult) ( _ outer As IQueryable(Of TOuter), _ inner As IEnumerable(Of TInner), _ outerKeySelector As Expression(Of Func(Of TOuter, TKey)), _ innerKeySelector As Expression(Of Func(Of TInner, TKey)), _ resultSelector As Expression(Of Func(Of TOuter, IEnumerable(Of TInner), TResult)) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> GroupJoin<TOuter, TInner, TKey, TResult>( this IQueryable<TOuter> outer, IEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, IEnumerable<TInner>, TResult>> resultSelector ) |
GroupJoin | 不支持 | Function GroupJoin(Of TOuter, TInner, TKey, TResult) ( _ outer As IQueryable(Of TOuter), _ inner As IEnumerable(Of TInner), _ outerKeySelector As Expression(Of Func(Of TOuter, TKey)), _ innerKeySelector As Expression(Of Func(Of TInner, TKey)), _ resultSelector As Expression(Of Func(Of TOuter, IEnumerable(Of TInner), TResult)), _ comparer As IEqualityComparer(Of TKey) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> GroupJoin\<TOuter, TInner, TKey, TResult>( this IQueryable<TOuter> outer, IEnumerable<TInner> inner, Expression<Func\<TOuter, TKey>> outerKeySelector, Expression<Func\<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, IEnumerable<TInner>, TResult>> resultSelector, IEqualityComparer<TKey> comparer ) |
Join | 支持 | Function Join(Of TOuter, TInner, TKey, TResult) ( _ outer As IQueryable(Of TOuter), _ inner As IEnumerable(Of TInner), _ outerKeySelector As Expression(Of Func(Of TOuter, TKey)), _ innerKeySelector As Expression(Of Func(Of TInner, TKey)), _ resultSelector As Expression(Of Func(Of TOuter, TInner, TResult)) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> Join<TOuter, TInner, TKey, TResult>( this IQueryable<TOuter> outer, IEnumerable<TInner> inner, Expression<Func<TOuter, TKey>> outerKeySelector, Expression<Func<TInner, TKey>> innerKeySelector, Expression<Func<TOuter, TInner, TResult>> resultSelector ) |
Join | 不支持 | Function Join(Of TOuter, TInner, TKey, TResult) ( _ outer As IQueryable(Of TOuter), _ inner As IEnumerable(Of TInner), _ outerKeySelector As Expression(Of Func(Of TOuter, TKey)), _ innerKeySelector As Expression(Of Func(Of TInner, TKey)), _ resultSelector As Expression(Of Func(Of TOuter, TInner, TResult)), _ comparer As IEqualityComparer(Of TKey) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> Join\<TOuter, TInner, TKey, TResult>( this IQueryable<TOuter> outer, IEnumerable<TInner> inner, Expression<Func\<TOuter, TKey>> outerKeySelector, Expression<Func\<TInner, TKey>> innerKeySelector, Expression<Func\<TOuter, TInner, TResult>> resultSelector, IEqualityComparer<TKey> comparer ) |
设置方法
除使用 EqualityComparer<T> 的方法外,LINQ to Entities 查询中支持大多数 LINQ 集方法。 有关更多信息,请参阅 LINQ to Entities 查询中的标准查询运算符。 下表列出了支持的和不支持的集方法。
方法 | 支持 | Visual Basic 函数签名 | C# 方法签名 |
---|---|---|---|
All | 支持 | Function All(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As Boolean |
bool All<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
Any | 受支持 | Function Any(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As Boolean |
bool Any<TSource>( this IQueryable<TSource> source ) |
Any | 受支持 | Function Any(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As Boolean |
bool Any<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
Contains | 受支持 | Function Contains(Of TSource) ( _ source As IQueryable(Of TSource), _ item As TSource _ ) As Boolean |
bool Contains<TSource>( this IQueryable<TSource> source, TSource item ) |
Contains | 不支持 | Function Contains(Of TSource) ( _ source As IQueryable(Of TSource), _ item As TSource, _ comparer As IEqualityComparer(Of TSource) _ ) As Boolean |
bool Contains<TSource>( this IQueryable<TSource> source, TSource item, IEqualityComparer<TSource> comparer ) |
Concat | 支持,但不保证 保留顺序 |
Function Concat(Of TSource) ( _ source1 As IQueryable(Of TSource), _ source2 As IEnumerable(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Concat<TSource>( this IQueryable<TSource> source1, IEnumerable<TSource> source2 ) |
DefaultIfEmpty | 支持 | Function DefaultIfEmpty(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> DefaultIfEmpty<TSource>( this IQueryable<TSource> source ) |
DefaultIfEmpty | 受支持 | Function DefaultIfEmpty(Of TSource) ( _ source As IQueryable(Of TSource), _ defaultValue As TSource _ ) As IQueryable(Of TSource) |
IQueryable<TSource> DefaultIfEmpty<TSource>( this IQueryable<TSource> source, TSource defaultValue ) |
Distinct | 受支持 | Function Distinct(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Distinct<TSource>( this IQueryable<TSource> source ) |
Distinct | 不支持 | Function Distinct(Of TSource) ( _ source As IQueryable(Of TSource), _ comparer As IEqualityComparer(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Distinct<TSource>( this IQueryable<TSource> source, IEqualityComparer<TSource> comparer ) |
Except | 支持 | Function Except(Of TSource) ( _ source1 As IQueryable(Of TSource), _ source2 As IEnumerable(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Except<TSource>( this IQueryable<TSource> source1, IEnumerable<TSource> source2 ) |
Except | 不支持 | Function Except(Of TSource) ( _ source1 As IQueryable(Of TSource), _ source2 As IEnumerable(Of TSource), _ comparer As IEqualityComparer(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Except<TSource>( this IQueryable<TSource> source1, IEnumerable<TSource> source2, IEqualityComparer<TSource> comparer ) |
Intersect | 支持 | Function Intersect(Of TSource) ( _ source1 As IQueryable(Of TSource), _ source2 As IEnumerable(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Intersect<TSource>( this IQueryable<TSource> source1, IEnumerable<TSource> source2 ) |
Intersect | 不支持 | Function Intersect(Of TSource) ( _ source1 As IQueryable(Of TSource), _ source2 As IEnumerable(Of TSource), _ comparer As IEqualityComparer(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Intersect<TSource>( this IQueryable<TSource> source1, IEnumerable<TSource> source2, IEqualityComparer<TSource> comparer ) |
Union | 支持 | Function Union(Of TSource) ( _ source1 As IQueryable(Of TSource), _ source2 As IEnumerable(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Union<TSource>( this IQueryable<TSource> source1, IEnumerable<TSource> source2 ) |
Union | 不支持 | Function Union(Of TSource) ( _ source1 As IQueryable(Of TSource), _ source2 As IEnumerable(Of TSource), _ comparer As IEqualityComparer(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Union<TSource>( this IQueryable<TSource> source1, IEnumerable<TSource> source2, IEqualityComparer<TSource> comparer ) |
排序方法
LINQ to Entities 支持大多数 LINQ 排序方法,但不支持接受 IComparer<T> 的排序方法,原因是比较器不能转换为数据源。 有关更多信息,请参阅 LINQ to Entities 查询中的标准查询运算符。 下表列出了支持的和不支持的排序方法。
方法 | 支持 | Visual Basic 函数签名 | C# 方法签名 |
---|---|---|---|
OrderBy | 支持 | Function OrderBy(Of TSource, TKey) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)) _ ) As IOrderedQueryable(Of TSource) |
IOrderedQueryable<TSource> OrderBy<TSource, TKey>( this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector ) |
OrderBy | 不支持 | Function OrderBy(Of TSource, TKey) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ comparer As IComparer(Of TKey) _ ) As IOrderedQueryable(Of TSource) |
IOrderedQueryable<TSource> OrderBy\<TSource, TKey>( this IQueryable<TSource> source, Expression<Func\<TSource, TKey>> keySelector, IComparer<TKey> comparer ) |
OrderByDescending | 支持 | Function OrderByDescending(Of TSource, TKey) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)) _ ) As IOrderedQueryable(Of TSource) |
IOrderedQueryable<TSource> OrderByDescending<TSource, TKey>( this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector ) |
OrderByDescending | 不支持 | Function OrderByDescending(Of TSource, TKey) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ comparer As IComparer(Of TKey) _ ) As IOrderedQueryable(Of TSource) |
IOrderedQueryable<TSource> OrderByDescending\<TSource, TKey>( this IQueryable<TSource> source, Expression<Func\<TSource, TKey>> keySelector, IComparer<TKey> comparer ) |
ThenBy | 支持 | Function ThenBy(Of TSource, TKey) ( _ source As IOrderedQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)) _ ) As IOrderedQueryable(Of TSource) |
IOrderedQueryable<TSource> ThenBy<TSource, TKey>( this IOrderedQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector ) |
ThenBy | 不支持 | Function ThenBy(Of TSource, TKey) ( _ source As IOrderedQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ comparer As IComparer(Of TKey) _ ) As IOrderedQueryable(Of TSource) |
IOrderedQueryable<TSource> ThenBy\<TSource, TKey>( this IOrderedQueryable<TSource> source, Expression<Func\<TSource, TKey>> keySelector, IComparer<TKey> comparer ) |
ThenByDescending | 支持 | Function ThenByDescending(Of TSource, TKey) ( _ source As IOrderedQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)) _ ) As IOrderedQueryable(Of TSource) |
IOrderedQueryable<TSource> ThenByDescending<TSource, TKey>( this IOrderedQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector ) |
ThenByDescending | 不支持 | Function ThenByDescending(Of TSource, TKey) ( _ source As IOrderedQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ comparer As IComparer(Of TKey) _ ) As IOrderedQueryable(Of TSource) |
IOrderedQueryable<TSource> ThenByDescending\<TSource, TKey>( this IOrderedQueryable<TSource> source, Expression<Func\<TSource, TKey>> keySelector, IComparer<TKey> comparer ) |
Reverse | 不支持 | Function Reverse(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Reverse<TSource>( this IQueryable<TSource> source ) |
分组方法
LINQ to Entities 支持大多数 LINQ 分组方法,但不支持接受 IEqualityComparer<T> 的分组方法,原因是比较器不能转换为数据源。 有关更多信息,请参阅 LINQ to Entities 查询中的标准查询运算符。 下表列出了支持的和不支持的分组方法。
方法 | 支持 | Visual Basic 函数签名 | C# 方法签名 |
---|---|---|---|
GroupBy | 支持 | Function GroupBy(Of TSource, TKey) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)) _ ) As IQueryable(Of IGrouping(Of TKey, TSource)) |
IQueryable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>( this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector ) |
GroupBy | 不支持 | Function GroupBy(Of TSource, TKey) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ comparer As IEqualityComparer(Of TKey) _ ) As IQueryable(Of IGrouping(Of TKey, TSource)) |
IQueryable<IGrouping\<TKey, TSource>> GroupBy\<TSource, TKey>( this IQueryable<TSource> source, Expression<Func\<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer ) |
GroupBy | 支持 | Function GroupBy(Of TSource, TKey, TElement) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ elementSelector As Expression(Of Func(Of TSource, TElement)) _ ) As IQueryable(Of IGrouping(Of TKey, TElement)) |
IQueryable<IGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>( this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector ) |
GroupBy | 受支持 | Function GroupBy(Of TSource, TKey, TResult) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ resultSelector As Expression(Of Func(Of TKey, IEnumerable(Of TSource), TResult)) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> GroupBy\<TSource, TKey, TResult>( this IQueryable<TSource> source, Expression<Func\<TSource, TKey>> keySelector, Expression<Func<TKey, IEnumerable<TSource>, TResult>> resultSelector ) |
GroupBy | 不支持 | Function GroupBy(Of TSource, TKey, TElement) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ elementSelector As Expression(Of Func(Of TSource, TElement)), _ comparer As IEqualityComparer(Of TKey) _ ) As IQueryable(Of IGrouping(Of TKey, TElement)) |
IQueryable<IGrouping\<TKey, TElement>> GroupBy\<TSource, TKey, TElement>( this IQueryable<TSource> source, Expression<Func\<TSource, TKey>> keySelector, Expression<Func\<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer |
GroupBy | 支持 | Function GroupBy(Of TSource, TKey, TElement, TResult) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ elementSelector As Expression(Of Func(Of TSource, TElement)), _ resultSelector As Expression(Of Func(Of TKey, IEnumerable(Of TElement), TResult)) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> GroupBy<TSource, TKey, TElement, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<TKey, IEnumerable<TElement>, TResult>> resultSelector ) |
GroupBy | 不支持 | Function GroupBy(Of TSource, TKey, TResult) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ resultSelector As Expression(Of Func(Of TKey, IEnumerable(Of TSource), TResult)), _ comparer As IEqualityComparer(Of TKey) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> GroupBy\<TSource, TKey, TResult>( this IQueryable<TSource> source, Expression<Func\<TSource, TKey>> keySelector, Expression<Func<TKey, IEnumerable<TSource>, TResult>> resultSelector, IEqualityComparer<TKey> comparer ) |
GroupBy | 不支持 | Function GroupBy(Of TSource, TKey, TElement, TResult) ( _ source As IQueryable(Of TSource), _ keySelector As Expression(Of Func(Of TSource, TKey)), _ elementSelector As Expression(Of Func(Of TSource, TElement)), _ resultSelector As Expression(Of Func(Of TKey, IEnumerable(Of TElement), TResult)), _ comparer As IEqualityComparer(Of TKey) _ ) As IQueryable(Of TResult) |
IQueryable<TResult> GroupBy<TSource, TKey, TElement, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<TKey, IEnumerable<TElement>, TResult>> resultSelector, IEqualityComparer<TKey> comparer ) |
聚合方法
LINQ to Entities 中支持大多数接受基元数据类型的聚合方法。 有关更多信息,请参阅 LINQ to Entities 查询中的标准查询运算符。 下表列出了支持的和不支持的聚合方法。
方法 | 支持 | Visual Basic 函数签名 | C# 方法签名 |
---|---|---|---|
Aggregate | 不支持 | Function Aggregate(Of TSource) ( _ source As IQueryable(Of TSource), _ func As Expression(Of Func(Of TSource, TSource, TSource)) _ ) As TSource |
TSource Aggregate<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, TSource, TSource>> func ) |
Aggregate | 不支持 | Function Aggregate(Of TSource, TAccumulate) ( _ source As IQueryable(Of TSource), _ seed As TAccumulate, _ func As Expression(Of Func(Of TAccumulate, TSource, TAccumulate)) _ ) As TAccumulate |
TAccumulate Aggregate<TSource, TAccumulate>( this IQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> func ) |
Aggregate | 不支持 | Function Aggregate(Of TSource, TAccumulate, TResult) ( _ source As IQueryable(Of TSource), _ seed As TAccumulate, _ func As Expression(Of Func(Of TAccumulate, TSource, TAccumulate)), _ selector As Expression(Of Func(Of TAccumulate, TResult)) _ ) As TResult |
TResult Aggregate<TSource, TAccumulate, TResult>( this IQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> func, Expression<Func<TAccumulate, TResult>> selector ) |
Average | 支持 | Function Average ( _ source As IQueryable(Of Decimal) _ ) As Decimal |
decimal Average( this IQueryable<decimal> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Double) _ ) As Double |
double Average( this IQueryable<double> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Integer) _ ) As Double |
double Average( this IQueryable<int> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Long) _ ) As Double |
double Average( this IQueryable<long> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Nullable(Of Decimal)) _ ) As Nullable(Of Decimal) |
Nullable<decimal> Average( this IQueryable<Nullable<decimal>> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Nullable(Of Double)) _ ) As Nullable(Of Double) |
Nullable<double> Average( this IQueryable<Nullable<double>> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Nullable(Of Integer)) _ ) As Nullable(Of Double) |
Nullable<double> Average( this IQueryable<Nullable<int>> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Nullable(Of Long)) _ ) As Nullable(Of Double) |
Nullable<double> Average( this IQueryable<Nullable<long>> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Nullable(Of Single)) _ ) As Nullable(Of Single) |
Nullable<float> Average( this IQueryable<Nullable<float>> source ) |
Average | 受支持 | Function Average ( _ source As IQueryable(Of Single) _ ) As Single |
float Average( this IQueryable<float> source ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Integer)) _ ) As Double |
double Average<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, int>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Integer))) _ ) As Nullable(Of Double) |
Nullable<double> Average<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<int>>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Long)) _ ) As Double |
double Average<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, long>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Long))) _ ) As Nullable(Of Double) |
Nullable<double> Average<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<long>>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Single)) _ ) As Single |
float Average<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, float>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Single))) _ ) As Nullable(Of Single) |
Nullable<float> Average<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<float>>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Double)) _ ) As Double |
double Average<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, double>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Double))) _ ) As Nullable(Of Double) |
Nullable<double> Average<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<double>>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Decimal)) _ ) As Decimal |
decimal Average<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, decimal>> selector ) |
Average | 不支持 | Function Average(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Decimal))) _ ) As Nullable(Of Decimal) |
Nullable<decimal> Average<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<decimal>>> selector ) |
Count | 支持 | Function Count(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As Integer |
int Count<TSource>( this IQueryable<TSource> source ) |
Count | 不支持 | Function Count(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As Integer |
int Count<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
LongCount | 支持 | Function LongCount(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As Long |
long LongCount<TSource>( this IQueryable<TSource> source ) |
LongCount | 不支持 | Function LongCount(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As Long |
long LongCount<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
Max | 支持 | Function Max(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource |
TSource Max<TSource>( this IQueryable<TSource> source ) |
Max | 不支持 | Function Max(Of TSource, TResult) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, TResult)) _ ) As TResult |
TResult Max<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector ) |
Min | 支持 | Function Min(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource |
TSource Min<TSource>( this IQueryable<TSource> source ) |
Min | 不支持 | Function Min(Of TSource, TResult) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, TResult)) _ ) As TResult |
TResult Min<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector ) |
Sum | 支持 | Function Sum ( _ source As IQueryable(Of Decimal) _ ) As Decimal |
decimal Sum( this IQueryable<decimal> source ) |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Double) _ ) As Double |
double Sum( this IQueryable<double> source |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Integer) _ ) As Integer |
int Sum( this IQueryable<int> source ) |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Long) _ ) As Long |
long Sum( this IQueryable<long> source ) |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Nullable(Of Decimal)) _ ) As Nullable(Of Decimal) |
Nullable<decimal> Sum( this IQueryable<Nullable<decimal>> source ) |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Nullable(Of Double)) _ ) As Nullable(Of Double) |
Function Sum ( _ source As IQueryable(Of Nullable(Of Double)) _ ) As Nullable(Of Double)Nullable<double> Sum( this IQueryable<Nullable<double>> source ) |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Nullable(Of Integer)) _ ) As Nullable(Of Integer) |
Nullable<int> Sum( this IQueryable<Nullable<int>> source ) |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Nullable(Of Long)) _ ) As Nullable(Of Long) |
Nullable<long> Sum( this IQueryable<Nullable<long>> source ) |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Nullable(Of Single)) _ ) As Nullable(Of Single) |
Nullable<float> Sum( this IQueryable<Nullable<float>> source ) |
Sum | 受支持 | Function Sum ( _ source As IQueryable(Of Single) _ ) As Single |
float Sum( this IQueryable<float> source ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Integer)) _ ) As Integer |
int Sum<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, int>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Integer))) _ ) As Nullable(Of Integer) |
Nullable<int> Sum<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<int>>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Long)) _ ) As Long |
long Sum<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, long>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Long))) _ ) As Nullable(Of Long) |
Nullable<long> Sum<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<long>>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Single))) _ ) As Nullable(Of Single) |
Nullable<float> Sum<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<float>>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Single)) _ ) As Single |
float Sum<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, float>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Double)) _ ) As Double |
double Sum<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, double>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Double))) _ ) As Nullable(Of Double) |
Nullable<double> Sum<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<double>>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Decimal)) _ ) As Decimal |
decimal Sum<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, decimal>> selector ) |
Sum | 不支持 | Function Sum(Of TSource) ( _ source As IQueryable(Of TSource), _ selector As Expression(Of Func(Of TSource, Nullable(Of Decimal))) _ ) As Nullable(Of Decimal) |
Nullable<decimal> Sum<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, Nullable<decimal>>> selector ) |
类型方法
实体框架中支持用于处理 CLR 类型转换和测试的 LINQ 标准查询运算符。 LINQ to Entities 中仅支持映射到概念模型类型的 CLR 类型。 有关概念模型类型的列表,请参阅概念模型类型 (CSDL)。 下表列出了支持的和不支持的类型方法。
方法 | 支持 | Visual Basic 函数签名 | C# 方法签名 |
---|---|---|---|
Cast | 对 EDM 基元类型支持 | Function Cast(Of TResult) ( _ source As IQueryable _ ) As IQueryable(Of TResult) |
IQueryable<TResult> Cast<TResult>( this IQueryable source ) |
OfType | 对 EntityType 支持 | Function OfType(Of TResult) ( _ source As IQueryable _ ) As IQueryable(Of TResult) |
IQueryable<TResult> OfType<TResult>( this IQueryable source ) |
分页方法
许多 LINQ 分页方法在 LINQ to Entities 查询中不受支持。 有关更多信息,请参阅 LINQ to Entities 查询中的标准查询运算符。 下表列出了支持的和不支持的分页方法。
方法 | 支持 | Visual Basic 函数签名 | C# 方法签名 |
---|---|---|---|
ElementAt | 不支持 | Function ElementAt(Of TSource) ( _ source As IQueryable(Of TSource), _ index As Integer _ ) As TSource |
TSource ElementAt<TSource>( this IQueryable<TSource> source, int index ) |
ElementAtOrDefault | 不支持 | Function ElementAtOrDefault(Of TSource) ( _ source As IQueryable(Of TSource), _ index As Integer _ ) As TSource |
TSource ElementAtOrDefault<TSource>( this IQueryable<TSource> source, int index ) |
First | 支持 | Function First(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource |
TSource First<TSource>( this IQueryable<TSource> source ) |
First | 受支持 | Function First(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As TSource |
TSource First<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
FirstOrDefault | 受支持 | Function FirstOrDefault(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource |
TSource FirstOrDefault<TSource>( this IQueryable<TSource> source ) |
FirstOrDefault | 受支持 | Function FirstOrDefault(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As TSource |
TSource FirstOrDefault<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
Last | 不支持 | Function Last(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource |
TSource Last<TSource>( this IQueryable<TSource> source ) |
Last | 不支持 | Function Last(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As TSource |
TSource Last<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
LastOrDefault | 不支持 | Function LastOrDefault(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource |
TSource LastOrDefault<TSource>( this IQueryable<TSource> source ) |
LastOrDefault | 不支持 | Function LastOrDefault(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As TSource |
TSource LastOrDefault<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
Single | 支持 | Function Single(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource |
TSource Single<TSource>( this IQueryable<TSource> source ) |
Single | 受支持 | Function Single(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As TSource |
TSource Single<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
SingleOrDefault | 受支持 | Function SingleOrDefault(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource |
TSource SingleOrDefault<TSource>( this IQueryable<TSource> source ) |
SingleOrDefault | 受支持 | Function SingleOrDefault(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As TSource |
TSource SingleOrDefault<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
Skip | 受支持 | Function Skip(Of TSource) ( _ source As IQueryable(Of TSource), _ count As Integer _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Skip<TSource>( this IQueryable<TSource> source, int count ) |
SkipWhile | 不支持 | Function SkipWhile(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> SkipWhile<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
SkipWhile | 不支持 | Function SkipWhile(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Integer, Boolean)) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> SkipWhile<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, int, bool>> predicate ) |
Take | 支持 | Function Take(Of TSource) ( _ source As IQueryable(Of TSource), _ count As Integer _ ) As IQueryable(Of TSource) |
IQueryable<TSource> Take<TSource>( this IQueryable<TSource> source, int count ) |
TakeWhile | 不支持 | Function TakeWhile(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> TakeWhile<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, bool>> predicate ) |
TakeWhile | 不支持 | Function TakeWhile(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Integer, Boolean)) _ ) As IQueryable(Of TSource) |
IQueryable<TSource> TakeWhile<TSource>( this IQueryable<TSource> source, Expression<Func\<TSource, int, bool>> predicate ) |