ObjectQuery.Context ObjectQuery.Context ObjectQuery.Context ObjectQuery.Context Property

정의

이 개체 쿼리와 관련된 개체 컨텍스트를 가져옵니다.Gets the object context associated with this object query.

public:
 property System::Data::Objects::ObjectContext ^ Context { System::Data::Objects::ObjectContext ^ get(); };
public System.Data.Objects.ObjectContext Context { get; }
member this.Context : System.Data.Objects.ObjectContext
Public ReadOnly Property Context As ObjectContext

속성 값

ObjectContext 인스턴스와 관련된 ObjectQuery<T>입니다.The ObjectContext associated with this ObjectQuery<T> instance.

예제

이 항목의 예제는 기준으로 합니다 AdventureWorks Sales 모델합니다.The example in this topic is based on the AdventureWorks Sales Model. 예제에서는 이 ObjectContext 개체와 관련된 ObjectQuery<T> 개체를 가져옵니다.The example gets the ObjectContext object associated with this ObjectQuery<T> object.

using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    string queryString =
        @"SELECT VALUE contact FROM 
        AdventureWorksEntities.Contacts AS contact";

    ObjectQuery<Contact> contactQuery =
        new ObjectQuery<Contact>(queryString,
            context, MergeOption.NoTracking);

    // Get ObjectContext from ObjectQuery.
    ObjectContext objectContext = contactQuery.Context;
    Console.WriteLine("Connection string {0}",
        objectContext.Connection.ConnectionString);
}
Using context As New AdventureWorksEntities()
    Dim queryString As String = "SELECT VALUE contact FROM AdventureWorksEntities.Contacts AS contact"

    Dim contactQuery As New ObjectQuery(Of Contact)(queryString, context, MergeOption.NoTracking)

    ' Get ObjectContext from ObjectQuery. 
    Dim objectContext As ObjectContext = contactQuery.Context
    Console.WriteLine("Connection string {0}", objectContext.Connection.ConnectionString)
End Using

설명

쿼리의 컨텍스트에는 연결, 캐시 및 메타데이터가 포함됩니다.The context for the query includes the connection, cache, and metadata. 자세한 내용은 개체 서비스 개요(Entity Framework)를 참조하세요.For more information, see Object Services Overview (Entity Framework).

연결 속성은 변경할 수 있으며 쿼리를 실행하기 전에 설정해야 합니다.The connection property is mutable and must be set before a query can be executed. 자세한 내용은 개체 서비스 (Entity Framework)에서 연결 관리합니다.For more information, see Managing Connections in Object Services (Entity Framework).

적용 대상

추가 정보