Queryable.Except 메서드

정의

두 시퀀스의 차집합을 구합니다.Produces the set difference of two sequences.

오버로드

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

지정된 IEqualityComparer<T>로 값을 비교하여 두 시퀀스의 차집합을 구합니다.Produces the set difference of two sequences by using the specified IEqualityComparer<T> to compare values.

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

기본 같음 비교자로 값을 비교하여 두 시퀀스의 차집합을 구합니다.Produces the set difference of two sequences by using the default equality comparer to compare values.

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

지정된 IEqualityComparer<T>로 값을 비교하여 두 시퀀스의 차집합을 구합니다.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);
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)

형식 매개 변수

TSource

입력 시퀀스 요소의 형식입니다.The type of the elements of the input sequences.

매개 변수

source1
IQueryable<TSource>

source2에 없는 해당 요소를 반환할 IQueryable<T>입니다.An IQueryable<T> whose elements that are not also in source2 will be returned.

source2
IEnumerable<TSource>

첫 번째 시퀀스에 해당 요소가 있는 경우 반환되는 시퀀스에서 해당 요소를 제외할 IEnumerable<T>입니다.An IEnumerable<T> whose elements that also occur in the first sequence will not appear in the returned sequence.

comparer
IEqualityComparer<TSource>

값을 비교할 IEqualityComparer<T>입니다.An IEqualityComparer<T> to compare values.

반환

IQueryable<TSource>

두 시퀀스의 차집합이 들어 있는 IQueryable<T>입니다.An IQueryable<T> that contains the set difference of the two sequences.

예외

source1 또는 source2null인 경우source1 or source2 is null.

설명

Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)메서드는 자신을 MethodCallExpression 생성 된 제네릭 메서드로 호출 하는을 생성 합니다 Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) .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. 그런 다음 MethodCallExpression CreateQuery<TElement>(Expression) IQueryProvider Provider 매개 변수의 속성이 나타내는의 메서드에를 전달 합니다 source1 .It then passes the MethodCallExpression to the CreateQuery<TElement>(Expression) method of the IQueryProvider represented by the Provider property of thesource1 parameter.

호출을 나타내는 식 트리를 실행 한 결과로 발생 하는 쿼리 동작은 Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>) 매개 변수의 형식 구현에 따라 달라 집니다 source1 .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. 예상 되는 동작은에 source1source2 있고 comparer 값을 비교 하는 데 사용 되는를 제외 하 고의 모든 요소가 반환 되는 것입니다.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>)

기본 같음 비교자로 값을 비교하여 두 시퀀스의 차집합을 구합니다.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)

형식 매개 변수

TSource

입력 시퀀스 요소의 형식입니다.The type of the elements of the input sequences.

매개 변수

source1
IQueryable<TSource>

source2에 없는 해당 요소를 반환할 IQueryable<T>입니다.An IQueryable<T> whose elements that are not also in source2 will be returned.

source2
IEnumerable<TSource>

첫 번째 시퀀스에 해당 요소가 있는 경우 반환되는 시퀀스에서 해당 요소를 제외할 IEnumerable<T>입니다.An IEnumerable<T> whose elements that also occur in the first sequence will not appear in the returned sequence.

반환

IQueryable<TSource>

두 시퀀스의 차집합이 들어 있는 IQueryable<T>입니다.An IQueryable<T> that contains the set difference of the two sequences.

예외

source1 또는 source2null인 경우source1 or source2 is null.

예제

다음 코드 예제에서는를 사용 하 여 Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) 첫 번째 소스 시퀀스에만 표시 되는 요소를 반환 하는 방법을 보여 줍니다.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

설명

Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>)메서드는 자신을 MethodCallExpression 생성 된 제네릭 메서드로 호출 하는을 생성 합니다 Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) .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. 그런 다음 MethodCallExpression CreateQuery<TElement>(Expression) IQueryProvider Provider 매개 변수의 속성이 나타내는의 메서드에를 전달 합니다 source1 .It then passes the MethodCallExpression to the CreateQuery<TElement>(Expression) method of the IQueryProvider represented by the Provider property of thesource1 parameter.

호출을 나타내는 식 트리를 실행 한 결과로 발생 하는 쿼리 동작은 Except<TSource>(IQueryable<TSource>, IEnumerable<TSource>) 매개 변수의 형식 구현에 따라 달라 집니다 source1 .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. 예상 되는 동작은에도 있는 경우를 제외 하 고의 모든 요소가 반환 되는 것입니다 source1 source2 .The expected behavior is that all the elements in source1 are returned except for those that are also in source2.

적용 대상