DataServiceContext.LoadProperty 메서드

정의

데이터 서비스에서 지연 콘텐츠를 로드합니다.

오버로드

LoadProperty(Object, String)

데이터 서비스에서 지정된 속성에 대한 지연 콘텐츠를 로드합니다.

LoadProperty(Object, String, DataServiceQueryContinuation)

제공된 쿼리 연속 개체를 사용하여 데이터 서비스에서 관련 엔터티의 다음 페이지를 로드합니다.

LoadProperty(Object, String, Uri)

제공된 다음 링크 URI를 사용하여 관련 엔터티의 페이지를 로드합니다.

LoadProperty<T>(Object, String, DataServiceQueryContinuation<T>)

제공된 제네릭 쿼리 연속 개체를 사용하여 데이터 서비스에서 관련 엔터티의 다음 페이지를 로드합니다.

LoadProperty(Object, String)

데이터 서비스에서 지정된 속성에 대한 지연 콘텐츠를 로드합니다.

public:
 System::Data::Services::Client::QueryOperationResponse ^ LoadProperty(System::Object ^ entity, System::String ^ propertyName);
public System.Data.Services.Client.QueryOperationResponse LoadProperty (object entity, string propertyName);
member this.LoadProperty : obj * string -> System.Data.Services.Client.QueryOperationResponse
Public Function LoadProperty (entity As Object, propertyName As String) As QueryOperationResponse

매개 변수

entity
Object

로드할 속성을 포함하는 엔터티입니다.

propertyName
String

로드할 지정된 엔터티의 속성 이름입니다.

반환

로드 작업에 대한 응답입니다.

예제

다음 예제에서는 반환 Orders 된 각 instance 관련된 개체를 Customers 명시적으로 로드하는 방법을 보여줍니다. 이 예제에서는 WCF Data Services 완료할 때 만들어지는 Northwind 데이터 서비스를 기반으로 서비스 참조 추가 도구에서 생성된 를 사용합니다DataServiceContext.

// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);

try
{
    // Enumerate over the top 10 orders obtained from the context.
    foreach (Order order in context.Orders.Take(10))
    {
        // Explicitly load the customer for each order.
        context.LoadProperty(order, "Customer");

        // Write out customer and order information.
        Console.WriteLine("Customer: {0} - Order ID: {1}",
            order.Customer.CompanyName, order.OrderID);
    }
}
catch (DataServiceQueryException ex)
{
    throw new ApplicationException(
        "An error occurred during query execution.", ex);
}
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)

Try
    ' Enumerate over the top 10 orders obtained from the context.
    For Each order As Order In context.Orders.Take(10)
        ' Explicitly load the customer for each order.
        context.LoadProperty(order, "Customer")

        ' Write out customer and order information.
        Console.WriteLine("Customer: {0} - Order ID: {1}", _
                order.Customer.CompanyName, order.OrderID)
    Next
Catch ex As DataServiceQueryException
    Throw New ApplicationException( _
            "An error occurred during query execution.", ex)
End Try

설명

이 메서드를 호출하면 네트워크 작업을 호출하여 속성 값을 가져옵니다. 지정된 속성은 연결 또는 링크를 나타내는 속성을 포함하여 엔터티의 속성 중 하나일 수 있습니다.

속성이 연결, 링크 또는 지연된 속성을 나타내는 경우 이 메서드를 호출하면 클라이언트에서 관련 리소스를 지연 로드할 수 있습니다.

엔터티가 변경되지 않거나 수정된 상태인 경우 속성 값은 관련 엔터티를 로드하고 변경되지 않은 링크로 변경되지 않은 상태로 표시합니다.

속성이 이미 로드된 경우 이 메서드를 호출하면 속성 값을 새로 고칠 수 있습니다.

적용 대상

LoadProperty(Object, String, DataServiceQueryContinuation)

제공된 쿼리 연속 개체를 사용하여 데이터 서비스에서 관련 엔터티의 다음 페이지를 로드합니다.

public:
 System::Data::Services::Client::QueryOperationResponse ^ LoadProperty(System::Object ^ entity, System::String ^ propertyName, System::Data::Services::Client::DataServiceQueryContinuation ^ continuation);
public System.Data.Services.Client.QueryOperationResponse LoadProperty (object entity, string propertyName, System.Data.Services.Client.DataServiceQueryContinuation continuation);
member this.LoadProperty : obj * string * System.Data.Services.Client.DataServiceQueryContinuation -> System.Data.Services.Client.QueryOperationResponse
Public Function LoadProperty (entity As Object, propertyName As String, continuation As DataServiceQueryContinuation) As QueryOperationResponse

매개 변수

entity
Object

로드할 속성을 포함하는 엔터티입니다.

propertyName
String

로드할 지정된 엔터티의 속성 이름입니다.

continuation
DataServiceQueryContinuation

데이터 서비스에서 로드할 관련 엔터티의 다음 페이지를 나타내는 DataServiceQueryContinuation<T> 개체입니다.

반환

관련 엔터티 데이터의 다음 페이지를 포함하는 응답입니다.

예외

entityDetached 또는 Added 상태에 있습니다.

설명

Unchanged 또는 상태이면 entity 관련 엔터티가 상태의 개체 Unchanged 로 로드되고 링크도 상태입니다 UnchangedModified.

가 상태에 있는 Deleted 경우 entity 관련 엔터티는 상태의 개체 Unchanged 로 로드되고 상태에 있는 링크가 Deleted 있습니다.

적용 대상

LoadProperty(Object, String, Uri)

제공된 다음 링크 URI를 사용하여 관련 엔터티의 페이지를 로드합니다.

public:
 System::Data::Services::Client::QueryOperationResponse ^ LoadProperty(System::Object ^ entity, System::String ^ propertyName, Uri ^ nextLinkUri);
public System.Data.Services.Client.QueryOperationResponse LoadProperty (object entity, string propertyName, Uri nextLinkUri);
member this.LoadProperty : obj * string * Uri -> System.Data.Services.Client.QueryOperationResponse
Public Function LoadProperty (entity As Object, propertyName As String, nextLinkUri As Uri) As QueryOperationResponse

매개 변수

entity
Object

로드할 속성을 포함하는 엔터티입니다.

propertyName
String

로드할 지정된 엔터티의 속성 이름입니다.

nextLinkUri
Uri

다음 결과 페이지를 로드하는 데 사용되는 URI입니다.

반환

요청 결과가 포함된 QueryOperationResponse<T>의 인스턴스입니다.

예외

entityDetached 또는 Added 상태인 경우

예제

이 예제에서는 각 Customers 엔터티와 관련된 Orders 엔터티를 반환하고 루프를 do…whileCustomers 사용하여 엔터티 페이지와 중첩된 while 루프를 사용하여 데이터 서비스에서 관련 Orders 엔터티의 페이지를 로드합니다. 메서드는 LoadProperty 관련 Orders 엔터티의 페이지를 로드하는 데 사용됩니다.

// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);
DataServiceQueryContinuation<Customer> nextLink = null;
int pageCount = 0;
int innerPageCount = 0;

try
{
    // Execute the query for all customers and related orders,
    // and get the response object.
    var response =
        context.Customers.AddQueryOption("$expand", "Orders")
        .Execute() as QueryOperationResponse<Customer>;

    // With a paged response from the service, use a do...while loop
    // to enumerate the results before getting the next link.
    do
    {
        // Write the page number.
        Console.WriteLine("Customers Page {0}:", ++pageCount);

        // If nextLink is not null, then there is a new page to load.
        if (nextLink != null)
        {
            // Load the new page from the next link URI.
            response = context.Execute<Customer>(nextLink)
                as QueryOperationResponse<Customer>;
        }

        // Enumerate the customers in the response.
        foreach (Customer c in response)
        {
            Console.WriteLine("\tCustomer Name: {0}", c.CompanyName);
            Console.WriteLine("\tOrders Page {0}:", ++innerPageCount);
            // Get the next link for the collection of related Orders.
            DataServiceQueryContinuation<Order> nextOrdersLink =
                response.GetContinuation(c.Orders);

            while (nextOrdersLink != null)
            {
                foreach (Order o in c.Orders)
                {
                    // Print out the orders.
                    Console.WriteLine("\t\tOrderID: {0} - Freight: ${1}",
                        o.OrderID, o.Freight);
                }

                // Load the next page of Orders.
                var ordersResponse = context.LoadProperty(c, "Orders", nextOrdersLink);
                nextOrdersLink = ordersResponse.GetContinuation();
            }
        }
    }

    // Get the next link, and continue while there is a next link.
    while ((nextLink = response.GetContinuation()) != null);
}
catch (DataServiceQueryException ex)
{
    throw new ApplicationException(
        "An error occurred during query execution.", ex);
}
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)
Dim nextLink As DataServiceQueryContinuation(Of Customer) = Nothing
Dim pageCount = 0
Dim innerPageCount = 0

Try
    ' Execute the query for all customers and related orders,
    ' and get the response object.
    Dim response = _
    CType(context.Customers.AddQueryOption("$expand", "Orders") _
            .Execute(), QueryOperationResponse(Of Customer))

    ' With a paged response from the service, use a do...while loop 
    ' to enumerate the results before getting the next link.
    Do
        ' Write the page number.
        Console.WriteLine("Customers Page {0}:", ++pageCount)

        ' If nextLink is not null, then there is a new page to load.
        If nextLink IsNot Nothing Then
            ' Load the new page from the next link URI.
            response = CType(context.Execute(Of Customer)(nextLink),  _
                    QueryOperationResponse(Of Customer))
        End If

        ' Enumerate the customers in the response.
        For Each c As Customer In response
            Console.WriteLine(vbTab & "Customer Name: {0}", c.CompanyName)
            Console.WriteLine(vbTab & "Orders Page {0}:", innerPageCount + 1)

            ' Get the next link for the collection of related Orders.
            Dim nextOrdersLink As DataServiceQueryContinuation(Of Order) = _
            response.GetContinuation(c.Orders)

            While nextOrdersLink IsNot Nothing
                For Each o As Order In c.Orders
                    ' Print out the orders.
                    Console.WriteLine(vbTab & vbTab & "OrderID: {0} - Freight: ${1}", _
                            o.OrderID, o.Freight)
                Next
                ' Load the next page of Orders.
                Dim ordersResponse = _
                context.LoadProperty(c, "Orders", nextOrdersLink)
                nextOrdersLink = ordersResponse.GetContinuation()
            End While
        Next
        ' Get the next link, and continue while there is a next link.
        nextLink = response.GetContinuation()
    Loop While nextLink IsNot Nothing
Catch ex As DataServiceQueryException
    Throw New ApplicationException( _
            "An error occurred during query execution.", ex)
End Try

설명

Unchanged 또는 상태이면 entity 관련 엔터티가 상태로 로드 Unchanged 되고 엔터티 간의 링크도 상태로 만들어집니다 UnchangedModified.

entity 가 상태에 있으면 Deleted 관련 엔터티가 상태로 로드 Unchanged 되고 엔터티 간의 링크가 상태에서 만들어집니다Deleted.

추가 정보

적용 대상

LoadProperty<T>(Object, String, DataServiceQueryContinuation<T>)

제공된 제네릭 쿼리 연속 개체를 사용하여 데이터 서비스에서 관련 엔터티의 다음 페이지를 로드합니다.

public:
generic <typename T>
 System::Data::Services::Client::QueryOperationResponse<T> ^ LoadProperty(System::Object ^ entity, System::String ^ propertyName, System::Data::Services::Client::DataServiceQueryContinuation<T> ^ continuation);
public System.Data.Services.Client.QueryOperationResponse<T> LoadProperty<T> (object entity, string propertyName, System.Data.Services.Client.DataServiceQueryContinuation<T> continuation);
member this.LoadProperty : obj * string * System.Data.Services.Client.DataServiceQueryContinuation<'T> -> System.Data.Services.Client.QueryOperationResponse<'T>
Public Function LoadProperty(Of T) (entity As Object, propertyName As String, continuation As DataServiceQueryContinuation(Of T)) As QueryOperationResponse(Of T)

형식 매개 변수

T

로드할 컬렉션의 요소 형식입니다.

매개 변수

entity
Object

로드할 속성을 포함하는 엔터티입니다.

propertyName
String

로드할 지정된 엔터티의 속성 이름입니다.

continuation
DataServiceQueryContinuation<T>

데이터 서비스에서 로드할 관련 엔터티의 다음 페이지를 나타내는 DataServiceQueryContinuation<T> 개체입니다.

반환

관련 엔터티 데이터의 다음 페이지를 포함하는 응답입니다.

예외

entityDetached 또는 Added 상태에 있습니다.

설명

Unchanged 또는 상태이면 entity 관련 엔터티가 상태의 개체 Unchanged 로 로드되고 링크도 상태입니다 UnchangedModified.

가 상태에 있는 Deleted 경우 entity 관련 엔터티는 상태의 개체 Unchanged 로 로드되고 상태에 있는 링크가 Deleted 있습니다.

적용 대상