ObjectQuery<T>.Intersect(ObjectQuery<T>) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
別のオブジェクト クエリに存在する結果のみを含めることで、クエリ結果を制限します。
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されているか、空の文字列です。
例
この例では、他の 2 つのクエリの結果を含む新しい 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で一意である必要があります。 同じ名前の結合コレクションに 2 つのパラメーターを指定することはできません。 詳細については、「 クエリ ビルダーメソッド」を参照してください。
結果のクエリは、Intersect メソッドが呼び出されたObjectQuery<T> インスタンスから接続を継承します。