Queryable.Except Queryable.Except Queryable.Except Queryable.Except Method

Definizione

Produce la differenza insiemistica di due sequenze.Produces the set difference of two sequences.

Overload

Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

Produce la differenza insiemistica di due sequenze utilizzando l'oggetto specificato IEqualityComparer<T> per confrontare i valori.Produces the set difference of two sequences by using the specified IEqualityComparer<T> to compare values.

Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>)

Produce la differenza insiemistica di due sequenze utilizzando l'operatore di confronto uguaglianze predefinito per confrontare valori.Produces the set difference of two sequences by using the default equality comparer to compare values.

Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)

Produce la differenza insiemistica di due sequenze utilizzando l'oggetto specificato IEqualityComparer<T> per confrontare i valori.Produces the set difference of two sequences by using the specified IEqualityComparer<T> to compare values.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IQueryable<TSource> ^ Except(System::Linq::IQueryable<TSource> ^ source1, System::Collections::Generic::IEnumerable<TSource> ^ source2, System::Collections::Generic::IEqualityComparer<TSource> ^ comparer);
public static System.Linq.IQueryable<TSource> Except<TSource> (this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TSource> source2, System.Collections.Generic.IEqualityComparer<TSource> comparer);
static member Except : System.Linq.IQueryable<'Source> * seq<'Source> * System.Collections.Generic.IEqualityComparer<'Source> -> System.Linq.IQueryable<'Source>
<Extension()>
Public Function Except(Of TSource) (source1 As IQueryable(Of TSource), source2 As IEnumerable(Of TSource), comparer As IEqualityComparer(Of TSource)) As IQueryable(Of TSource)

Parametri di tipo

TSource

Tipo degli elementi delle sequenze di input.The type of the elements of the input sequences.

Parametri

source1
IQueryable<TSource>

Un' IQueryable<T> cui elementi che non sono presenti anche in source2 verranno restituiti.An IQueryable<T> whose elements that are not also in source2 will be returned.

source2
IEnumerable<TSource>

Un IEnumerable<T> cui elementi che sono presenti anche nella prima sequenza non compariranno nella sequenza restituita.An IEnumerable<T> whose elements that also occur in the first sequence will not appear in the returned sequence.

comparer
IEqualityComparer<TSource>

Oggetto IEqualityComparer<T> per confrontare i valori.An IEqualityComparer<T> to compare values.

Restituisce

IQueryable<TSource>

Un IQueryable<T> che contiene la differenza insiemistica di due sequenze.An IQueryable<T> that contains the set difference of the two sequences.

Eccezioni

source1 o source2 è null.source1 or source2 is null.

Commenti

Il Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) metodo genera un MethodCallExpression che rappresenta una chiamata Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) stesso come un metodo generico costruito.The Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) method generates a MethodCallExpression that represents calling Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) itself as a constructed generic method. Passa quindi il MethodCallExpression per il CreateQuery<TElement>(Expression) metodo del IQueryProvider rappresentato dal Provider proprietà delsource1 parametro.It then passes the MethodCallExpression to the CreateQuery<TElement>(Expression) method of the IQueryProvider represented by the Provider property of thesource1 parameter.

Il comportamento delle query che si verifica in seguito all'esecuzione di un albero delle espressioni che rappresenta una chiamata Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) dipende dall'implementazione del tipo del source1 parametro.The query behavior that occurs as a result of executing an expression tree that represents calling Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) depends on the implementation of the type of the source1 parameter. Il comportamento previsto è che tutti gli elementi source1 vengono restituiti ad eccezione di quelli che sono presenti anche nella source2, e comparer viene usata per confrontare valori.The expected behavior is that all the elements in source1 are returned except for those that are also in source2, and comparer is used to compare values.

Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>)

Produce la differenza insiemistica di due sequenze utilizzando l'operatore di confronto uguaglianze predefinito per confrontare valori.Produces the set difference of two sequences by using the default equality comparer to compare values.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IQueryable<TSource> ^ Except(System::Linq::IQueryable<TSource> ^ source1, System::Collections::Generic::IEnumerable<TSource> ^ source2);
public static System.Linq.IQueryable<TSource> Except<TSource> (this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TSource> source2);
static member Except : System.Linq.IQueryable<'Source> * seq<'Source> -> System.Linq.IQueryable<'Source>
<Extension()>
Public Function Except(Of TSource) (source1 As IQueryable(Of TSource), source2 As IEnumerable(Of TSource)) As IQueryable(Of TSource)

Parametri di tipo

TSource

Tipo degli elementi delle sequenze di input.The type of the elements of the input sequences.

Parametri

source1
IQueryable<TSource>

Un' IQueryable<T> cui elementi che non sono presenti anche in source2 verranno restituiti.An IQueryable<T> whose elements that are not also in source2 will be returned.

source2
IEnumerable<TSource>

Un IEnumerable<T> cui elementi che sono presenti anche nella prima sequenza non compariranno nella sequenza restituita.An IEnumerable<T> whose elements that also occur in the first sequence will not appear in the returned sequence.

Restituisce

IQueryable<TSource>

Un IQueryable<T> che contiene la differenza insiemistica di due sequenze.An IQueryable<T> that contains the set difference of the two sequences.

Eccezioni

source1 o source2 è null.source1 or source2 is null.

Esempi

Esempio di codice seguente viene illustrato come utilizzare Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) per restituire gli elementi che vengono visualizzati solo nella prima sequenza di origine.The following code example demonstrates how to use Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) to return those elements that only appear in the first source sequence.

double[] numbers1 = { 2.0, 2.1, 2.2, 2.3, 2.4, 2.5 };
double[] numbers2 = { 2.2 };

// Get the numbers from the first array that
// are NOT in the second array.
IEnumerable<double> onlyInFirstSet =
    numbers1.AsQueryable().Except(numbers2);

foreach (double number in onlyInFirstSet)
    Console.WriteLine(number);

/*
    This code produces the following output:

    2
    2.1
    2.3
    2.4
    2.5
*/

Dim numbers1() As Double = {2.0, 2.1, 2.2, 2.3, 2.4, 2.5}
Dim numbers2() As Double = {2.2}

' Get the numbers from the first array that
' are NOT in the second array.
Dim onlyInFirstSet As IEnumerable(Of Double) = _
    numbers1.AsQueryable().Except(numbers2)

Dim output As New System.Text.StringBuilder
For Each number As Double In onlyInFirstSet
    output.AppendLine(number)
Next

' Display the output.
MsgBox(output.ToString())

' This code produces the following output:
'
' 2
' 2.1
' 2.3
' 2.4
' 2.5

Commenti

Il Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) metodo genera un MethodCallExpression che rappresenta una chiamata Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) stesso come un metodo generico costruito.The Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) method generates a MethodCallExpression that represents calling Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) itself as a constructed generic method. Passa quindi il MethodCallExpression per il CreateQuery<TElement>(Expression) metodo del IQueryProvider rappresentato dal Provider proprietà delsource1 parametro.It then passes the MethodCallExpression to the CreateQuery<TElement>(Expression) method of the IQueryProvider represented by the Provider property of thesource1 parameter.

Il comportamento delle query che si verifica in seguito all'esecuzione di un albero delle espressioni che rappresenta una chiamata Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) dipende dall'implementazione del tipo del source1 parametro.The query behavior that occurs as a result of executing an expression tree that represents calling Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) depends on the implementation of the type of the source1 parameter. Il comportamento previsto è che tutti gli elementi source1 vengono restituiti ad eccezione di quelli che sono presenti anche in source2.The expected behavior is that all the elements in source1 are returned except for those that are also in source2.

Si applica a