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

정의

다른 개체 쿼리에 있는 결과만 포함하여 쿼리 결과를 제한합니다.

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

매개 변수

query
ObjectQuery<T>

쿼리에 포함할 결과를 나타내는 ObjectQuery<T>입니다.

반환

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

예외

query 매개 변수가 null 또는 빈 문자열인 경우

예제

이 예제에서는 다른 두 쿼리의 결과를 포함하는 새 ObjectQuery<T> 개체를 만듭니다.

int productID1 = 900;
int productID2 = 950;
using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    string queryString = @"SELECT VALUE product
        FROM AdventureWorksEntities.Products
        AS product WHERE product.ProductID > @productID1";

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

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

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

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

    productQuery3.Parameters.Add(new ObjectParameter("productID1", productID1));
    productQuery3.Parameters.Add(new ObjectParameter("productID2", productID2));

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

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

설명

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

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

결과 쿼리는 메서드가 호출된 Intersect 인스턴스에서 ObjectQuery<T> 연결을 상속합니다.

적용 대상

추가 정보