ObjectQuery<T>.Except(ObjectQuery<T>) 메서드

정의

다른 개체 쿼리의 결과를 기반으로 결과를 제외시켜 쿼리 결과를 제한합니다.

public:
 System::Data::Objects::ObjectQuery<T> ^ Except(System::Data::Objects::ObjectQuery<T> ^ query);
public System.Data.Objects.ObjectQuery<T> Except (System.Data.Objects.ObjectQuery<T> query);
member this.Except : System.Data.Objects.ObjectQuery<'T> -> System.Data.Objects.ObjectQuery<'T>
Public Function Except (query As ObjectQuery(Of T)) As ObjectQuery(Of T)

매개 변수

query
ObjectQuery<T>

쿼리에서 제외시킬 결과를 나타내는 ObjectQuery<T>입니다.

반환

원래 인스턴스에 지정된 query를 기반으로 EXCEPT가 적용된 것과 동일한 새 ObjectQuery<T> 인스턴스입니다.

예외

query 매개 변수가 null이거나 빈 문자열인 경우

예제

이 예제에서는 메서드를 사용하여 ExceptObjectQuery<T> 개체를 만든 다음 새 쿼리의 결과를 반복합니다.

int productID = 900;
using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    string queryString = @"SELECT VALUE product
        FROM AdventureWorksEntities.Products AS product";

    ObjectQuery<Product> productQuery =
        new ObjectQuery<Product>(queryString,
            context, MergeOption.NoTracking);

    string queryString2 = @"SELECT VALUE product
        FROM AdventureWorksEntities.Products
        AS product WHERE product.ProductID < @productID";

    ObjectQuery<Product> productQuery2 =
        new ObjectQuery<Product>(queryString2,
            context, MergeOption.NoTracking);

    productQuery2.Parameters.Add(new ObjectParameter("productID", productID));

    ObjectQuery<Product> productQuery3 =
        productQuery.Except(productQuery2);

    Console.WriteLine("Result of Except");
    Console.WriteLine("------------------");

    // Iterate through the collection of Product items
    // after the Except method was called.
    foreach (Product result in productQuery3)
        Console.WriteLine("Product Name: {0}",
            result.ProductID);
}

설명

제외할 결과를 정의하는 제공된 query 는 와 호환 ObjectQuery<T>되는 형식 또는 형식과 동일해야 합니다.

제공 query 된 에 정의된 매개 변수는 instance 정의된 ObjectQuery<T> 매개 변수와 병합됩니다. 매개 변수는 결합된 ObjectParameterCollection에서 고유해야 합니다. 결합된 컬렉션에는 이름이 같은 두 개의 매개 변수가 있을 수 없습니다. 자세한 내용은 쿼리 작성기 메서드합니다.

결과 쿼리는 호출된 instance Except 연결을 ObjectQuery<T> 상속합니다.

적용 대상

추가 정보