ObjectQuery<T>.Where(String, ObjectParameter[]) 메서드


지정된 필터링 조건과 일치하는 결과로 쿼리를 제한합니다.Limits the query to results that match specified filtering criteria.

 System::Data::Objects::ObjectQuery<T> ^ Where(System::String ^ predicate, ... cli::array <System::Data::Objects::ObjectParameter ^> ^ parameters);
public System.Data.Objects.ObjectQuery<T> Where (string predicate, params System.Data.Objects.ObjectParameter[] parameters);
member this.Where : string * System.Data.Objects.ObjectParameter[] -> System.Data.Objects.ObjectQuery<'T>
Public Function Where (predicate As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of T)

매개 변수


필터 조건자입니다.The filter predicate.


이 메서드에 사용되는 0개 이상의 매개 변수입니다.Zero or more parameters that are used in this method.


원래 인스턴스에 WHERE가 적용된 것과 동일한 새 ObjectQuery<T> 인스턴스입니다.A new ObjectQuery<T> instance that is equivalent to the original instance with WHERE applied.


predicatenull인 경우predicate is null.

또는-or- parametersnull인 경우parameters is null.

predicate이 빈 문자열입니다.The predicate is an empty string.


이 예제는 기준으로 합니다 AdventureWorks Sales 모델합니다.This example is based on the AdventureWorks Sales Model. 이 예제에서는 새 ObjectQuery<T> 다음 기준으로 필터링 된 기존 쿼리의 결과 포함 하는: "it.ProductID = 900"합니다.The example creates a new ObjectQuery<T> that contains results of the existing query filtered by the following criteria: "it.ProductID = 900".

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

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

    ObjectQuery<Product> productQuery2 =
        productQuery1.Where("it.ProductID = @productID");

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

    // Iterate through the collection of Product items.
    foreach (Product result in productQuery2)
        Console.WriteLine("Product Name: {0}; Product ID: {1}",
            result.Name, result.ProductID);
Dim productID = 900
Using context As New AdventureWorksEntities()
    Dim queryString As String = "SELECT VALUE product FROM AdventureWorksEntities.Products AS product"

    Dim productQuery1 As New ObjectQuery(Of Product)(queryString, context, MergeOption.NoTracking)

    Dim productQuery2 As ObjectQuery(Of Product) = productQuery1.Where("it.ProductID = @productID")
    productQuery2.Parameters.Add(New ObjectParameter("productID", productID))

    ' Iterate through the collection of Product items. 
    For Each result As Product In productQuery2
        Console.WriteLine("Product Name: {0}; Product ID: {1}", result.Name, result.ProductID)
End Using

적용 대상

추가 정보