Métodos de LINQ compatibles y no compatibles (LINQ to Entities)Supported and Unsupported LINQ Methods (LINQ to Entities)

En esta sección se proporciona información sobre los operadores de consulta estándar de Language-Integrated Query (LINQ) que se admiten o no en LINQ a consultas de entidades.This section provides information about the Language-Integrated Query (LINQ) standard query operators that are supported or unsupported in LINQ to Entities queries. Muchos de los operadores de consulta estándar de LINQ tienen una versión sobrecargada que acepta un argumento entero.Many of the LINQ standard query operators have an overloaded version that accepts an integer argument. El argumento entero corresponde a un índice de base cero de la secuencia que se opera, un IEqualityComparer<T>, o IComparer<T>.The integer argument corresponds to a zero-based index in the sequence that is being operated on, an IEqualityComparer<T>, or IComparer<T>. A menos que se especifique lo contrario, estas versiones sobrecargadas de los operadores de consulta estándar de LINQ no se admiten y, si intenta utilizarlos, se iniciará una excepción.Unless otherwise specified, these overloaded versions of the LINQ standard query operators are not supported, and attempting to use them will throw an exception.

Métodos de restricción y proyecciónProjection and Restriction Methods

La mayoría de los métodos de restricción y proyección de LINQ es compatibles con LINQ a consultas de entidades, a excepción de las que aceptan un argumento posicional.Most of the LINQ projection and restriction methods are supported in LINQ to Entities queries, with the exception of those that accept a positional argument. Para obtener más información, consulte operadores de consulta estándar en consultas LINQ to Entities.For more information, see Standard Query Operators in LINQ to Entities Queries. En la tabla siguiente se enumeran los métodos de restricción y proyección admitidos y no admitidos.The following table lists the supported and unsupported projection and restriction methods.

MétodoMethod Soporte técnicoSupport Firma de funciones de Visual BasicVisual Basic function signature Firma de métodos de C#C# method signature
Select CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 )

Métodos de combinaciónJoin Methods

Los métodos de combinación LINQ se admiten en LINQ to Entities, a excepción de los que aceptan un IEqualityComparer porque el comparador no se puede convertir al origen de datos.The LINQ join methods are supported in LINQ to Entities, with the exception of those that accept an IEqualityComparer because the comparer cannot be translated to the data source. Para obtener más información, consulte operadores de consulta estándar en consultas LINQ to Entities.For more information, see Standard Query Operators in LINQ to Entities Queries. La tabla siguiente enumera los métodos de combinación admitidos y no admitidos.The following table lists the supported and unsupported join methods.

MétodoMethod Soporte técnicoSupport Firma de funciones de Visual BasicVisual Basic function signature Firma de métodos de C#C# method signature
GroupJoin CompatibleSupported 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 No admitidoNot Supported 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 CompatibleSupported 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 No admitidoNot Supported 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 )

Métodos SetSet Methods

La mayoría de los métodos set LINQ es compatibles con LINQ a consultas de entidades, a excepción de las que usan un EqualityComparer<T>.Most of the LINQ set methods are supported in LINQ to Entities queries, with the exception of those that use an EqualityComparer<T>. Para obtener más información, consulte operadores de consulta estándar en consultas LINQ to Entities.For more information, see Standard Query Operators in LINQ to Entities Queries. La tabla siguiente enumera los métodos Set admitidos y no admitidos.The following table lists the supported and unsupported set methods.

MétodoMethod Soporte técnicoSupport Firma de funciones de Visual BasicVisual Basic function signature Firma de métodos de C#C# method signature
All CompatibleSupported 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 CompatibleSupported Function Any(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As Boolean bool Any<TSource>( this IQueryable<TSource> source )
Any CompatibleSupported 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 CompatibleSupported Function Contains(Of TSource) ( _ source As IQueryable(Of TSource), _ item As TSource _ ) As Boolean bool Contains<TSource>( this IQueryable<TSource> source, TSource item )
Contains No compatiblesNot supported 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 Admitido, pero no hay ningunaSupported, but there is no

garantía de que se conserve el ordenguarantee of order being preserved
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 CompatibleSupported Function DefaultIfEmpty(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As IQueryable(Of TSource) IQueryable<TSource> DefaultIfEmpty<TSource>( this IQueryable<TSource> source )
DefaultIfEmpty CompatibleSupported 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 CompatibleSupported Function Distinct(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As IQueryable(Of TSource) IQueryable<TSource> Distinct<TSource>( this IQueryable<TSource> source )
Distinct No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 )

Métodos de ordenaciónOrdering Methods

La mayoría de lo métodos de ordenación de LINQ se admiten en LINQ to Entities, a excepción de las que aceptan un IComparer<T>, porque el comparador no se puede convertir al origen de datos.Most of the LINQ ordering methods are supported in LINQ to Entities, with the exception of those that accept an IComparer<T>, because the comparer cannot be translated to the data source. Para obtener más información, consulte operadores de consulta estándar en consultas LINQ to Entities.For more information, see Standard Query Operators in LINQ to Entities Queries. La tabla siguiente enumera los métodos de ordenación admitidos y no admitidos.The following table lists the supported and unsupported ordering methods.

MétodoMethod Soporte técnicoSupport Firma de funciones de Visual BasicVisual Basic function signature Firma de métodos de C#C# method signature
OrderBy CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 No compatiblesNot supported Function Reverse(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As IQueryable(Of TSource) IQueryable<TSource> Reverse<TSource>( this IQueryable<TSource> source )

Métodos de agrupamientoGrouping Methods

La mayoría de los métodos de agrupamiento de LINQ se admite en LINQ to Entities, a excepción de los que aceptan un IEqualityComparer<T>, porque el comparador no se puede convertir al origen de datos.Most of the LINQ grouping methods are supported in LINQ to Entities, with the exception of those that accept an IEqualityComparer<T>, because the comparer cannot be translated to the data source. Para obtener más información, consulte operadores de consulta estándar en consultas LINQ to Entities.For more information, see Standard Query Operators in LINQ to Entities Queries. La tabla siguiente enumera los métodos de agrupamiento admitidos y no admitidos.The following table lists the supported and unsupported grouping methods.

MétodoMethod Soporte técnicoSupport Firma de funciones de Visual BasicVisual Basic function signature Firma de métodos de C#C# method signature
GroupBy CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 CompatibleSupported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 )

Métodos de agregaciónAggregate Methods

Admite la mayoría de los métodos de agregación que aceptan tipos de datos primitivos en LINQ to Entities.Most of the aggregate methods that accept primitive data types are supported in LINQ to Entities. Para obtener más información, consulte operadores de consulta estándar en consultas LINQ to Entities.For more information, see Standard Query Operators in LINQ to Entities Queries. La tabla siguiente enumera los métodos de agregación admitidos y no admitidos.The following table lists the supported and unsupported aggregate methods.

MétodoMethod Soporte técnicoSupport Firma de funciones de Visual BasicVisual Basic function signature Firma de métodos de C#C# method signature
Aggregate No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 CompatibleSupported Function Average ( _ source As IQueryable(Of Decimal) _ ) As Decimal decimal Average( this IQueryable<decimal> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Double) _ ) As Double double Average( this IQueryable<double> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Integer) _ ) As Double double Average( this IQueryable<int> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Long) _ ) As Double double Average( this IQueryable<long> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Nullable(Of Decimal)) _ ) As Nullable(Of Decimal) Nullable<decimal> Average( this IQueryable<Nullable<decimal>> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Nullable(Of Double)) _ ) As Nullable(Of Double) Nullable<double> Average( this IQueryable<Nullable<double>> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Nullable(Of Integer)) _ ) As Nullable(Of Double) Nullable<double> Average( this IQueryable<Nullable<int>> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Nullable(Of Long)) _ ) As Nullable(Of Double) Nullable<double> Average( this IQueryable<Nullable<long>> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Nullable(Of Single)) _ ) As Nullable(Of Single) Nullable<float> Average( this IQueryable<Nullable<float>> source )
Average CompatibleSupported Function Average ( _ source As IQueryable(Of Single) _ ) As Single float Average( this IQueryable<float> source )
Average No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 CompatibleSupported Function Count(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As Integer int Count<TSource>( this IQueryable<TSource> source )
Count No compatiblesNot supported 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 CompatibleSupported Function LongCount(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As Long long LongCount<TSource>( this IQueryable<TSource> source )
LongCount No compatiblesNot supported 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 CompatibleSupported Function Max(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource TSource Max<TSource>( this IQueryable<TSource> source )
Max No compatiblesNot supported 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 CompatibleSupported Function Min(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource TSource Min<TSource>( this IQueryable<TSource> source )
Min No compatiblesNot supported 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 CompatibleSupported Function Sum ( _ source As IQueryable(Of Decimal) _ ) As Decimal decimal Sum( this IQueryable<decimal> source )
Sum CompatibleSupported Function Sum ( _ source As IQueryable(Of Double) _ ) As Double double Sum( this IQueryable<double> source
Sum CompatibleSupported Function Sum ( _ source As IQueryable(Of Integer) _ ) As Integer int Sum( this IQueryable<int> source )
Sum CompatibleSupported Function Sum ( _ source As IQueryable(Of Long) _ ) As Long long Sum( this IQueryable<long> source )
Sum CompatibleSupported Function Sum ( _ source As IQueryable(Of Nullable(Of Decimal)) _ ) As Nullable(Of Decimal) Nullable<decimal> Sum( this IQueryable<Nullable<decimal>> source )
Sum CompatibleSupported 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 CompatibleSupported Function Sum ( _ source As IQueryable(Of Nullable(Of Integer)) _ ) As Nullable(Of Integer) Nullable<int> Sum( this IQueryable<Nullable<int>> source )
Sum CompatibleSupported Function Sum ( _ source As IQueryable(Of Nullable(Of Long)) _ ) As Nullable(Of Long) Nullable<long> Sum( this IQueryable<Nullable<long>> source )
Sum CompatibleSupported Function Sum ( _ source As IQueryable(Of Nullable(Of Single)) _ ) As Nullable(Of Single) Nullable<float> Sum( this IQueryable<Nullable<float>> source )
Sum CompatibleSupported Function Sum ( _ source As IQueryable(Of Single) _ ) As Single float Sum( this IQueryable<float> source )
Sum No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 )

Métodos de tiposType Methods

Se admiten los operadores de consulta estándar de LINQ que se encargan de conversión de tipos CLR y las pruebas en Entity Framework.The LINQ standard query operators that deal with CLR type conversion and testing are supported in the Entity Framework. LINQ to Entities admite solo los tipos de CLR que se asignan a los tipos del modelo conceptual.Only CLR types that map to conceptual model types are supported in LINQ to Entities. Para obtener una lista de tipos del modelo conceptual, vea tipos de modelos conceptuales (CSDL).For a list of conceptual model types, see Conceptual Model Types (CSDL). La tabla siguiente enumera los métodos de tipos admitidos y no admitidos.The following table lists the supported and unsupported type methods.

MétodoMethod Soporte técnicoSupport Firma de funciones de Visual BasicVisual Basic function signature Firma de métodos de C#C# method signature
Cast Se admite para los tipos primitivos de EDMSupported for EDM primitive types Function Cast(Of TResult) ( _ source As IQueryable _ ) As IQueryable(Of TResult) IQueryable<TResult> Cast<TResult>( this IQueryable source )
OfType Se admite para EntityTypeSupported for EntityType Function OfType(Of TResult) ( _ source As IQueryable _ ) As IQueryable(Of TResult) IQueryable<TResult> OfType<TResult>( this IQueryable source )

Métodos de paginaciónPaging Methods

Un número de los métodos de paginación de LINQ no se admite en LINQ a consultas de entidades.A number of the LINQ paging methods are not supported in LINQ to Entities queries. Para obtener más información, consulte operadores de consulta estándar en consultas LINQ to Entities.For more information, see Standard Query Operators in LINQ to Entities Queries. La tabla siguiente enumera los métodos de paginación admitidos y no admitidos.The following table lists the supported and unsupported paging methods.

MétodoMethod Soporte técnicoSupport Firma de funciones de Visual BasicVisual Basic function signature Firma de métodos de C#C# method signature
ElementAt No compatiblesNot supported Function ElementAt(Of TSource) ( _ source As IQueryable(Of TSource), _ index As Integer _ ) As TSource TSource ElementAt<TSource>( this IQueryable<TSource> source, int index )
ElementAtOrDefault No compatiblesNot supported Function ElementAtOrDefault(Of TSource) ( _ source As IQueryable(Of TSource), _ index As Integer _ ) As TSource TSource ElementAtOrDefault<TSource>( this IQueryable<TSource> source, int index )
First CompatibleSupported Function First(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource TSource First<TSource>( this IQueryable<TSource> source )
First CompatibleSupported 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 CompatibleSupported Function FirstOrDefault(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource TSource FirstOrDefault<TSource>( this IQueryable<TSource> source )
FirstOrDefault CompatibleSupported 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 No compatiblesNot supported Function Last(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource TSource Last<TSource>( this IQueryable<TSource> source )
Last No compatiblesNot supported 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 No compatiblesNot supported Function LastOrDefault(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource TSource LastOrDefault<TSource>( this IQueryable<TSource> source )
LastOrDefault No compatiblesNot supported 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 CompatibleSupported Function Single(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource TSource Single<TSource>( this IQueryable<TSource> source )
Single CompatibleSupported 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 CompatibleSupported Function SingleOrDefault(Of TSource) ( _ source As IQueryable(Of TSource) _ ) As TSource TSource SingleOrDefault<TSource>( this IQueryable<TSource> source )
SingleOrDefault CompatibleSupported 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 CompatibleSupported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 CompatibleSupported 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 No compatiblesNot supported 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 No compatiblesNot supported 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 )

Vea tambiénSee also