다음을 통해 공유


DataServiceContext.LoadProperty 메서드 (Object, String)

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

Silverlight용 WCF Data Services 5.0 클라이언트에서 지원되지 않습니다.

네임스페이스:  System.Data.Services.Client
어셈블리:  Microsoft.Data.Services.Client(Microsoft.Data.Services.Client.dll)

구문

‘선언
Public Function LoadProperty ( _
    entity As Object, _
    propertyName As String _
) As QueryOperationResponse
‘사용 방법
Dim instance As DataServiceContext
Dim entity As Object
Dim propertyName As String
Dim returnValue As QueryOperationResponse

returnValue = instance.LoadProperty(entity, _
    propertyName)
public QueryOperationResponse LoadProperty(
    Object entity,
    string propertyName
)
public:
QueryOperationResponse^ LoadProperty(
    Object^ entity, 
    String^ propertyName
)
member LoadProperty : 
        entity:Object * 
        propertyName:string -> QueryOperationResponse 
public function LoadProperty(
    entity : Object, 
    propertyName : String
) : QueryOperationResponse

매개 변수

  • entity
    유형: System.Object
    로드할 속성을 포함하는 엔터티입니다.
  • propertyName
    유형: System.String
    로드할 지정된 엔터티의 속성 이름입니다.

반환 값

유형: System.Data.Services.Client.QueryOperationResponse
로드 작업에 대한 응답입니다.

주의

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

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

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

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

다음 예제에서는 반환되는 각 Orders 인스턴스와 관련된 Customers 개체를 명시적으로 로드하는 방법을 보여 줍니다. 이 예제에서는 WCF Data Services?퀵 스타트를 완료하면 생성되는 Northwind 데이터 서비스를 기반으로 서비스 참조 추가 도구에서 생성된 DataServiceContext를 사용합니다.

' 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
// 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);
}

참고 항목

참조

DataServiceContext 클래스

LoadProperty 오버로드

System.Data.Services.Client 네임스페이스