DataServiceContext.LoadProperty 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 서비스에서 지연된 콘텐츠를 로드합니다.
오버로드
| Name | Description |
|---|---|
| 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 된 각 인스턴스와 관련된 개체를 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> 데이터 서비스에서 로드할 관련 엔터티의 다음 페이지를 나타내는 개체입니다.
반품
관련 엔터티 데이터의 다음 페이지를 포함하는 응답입니다.
예외
설명
상태 또는 Modified 상태인 경우 entity 관련 엔터티는 상태의 개체 Unchanged 로 로드되고 링크도 상태입니다Unchanged.Unchanged
상태에 있는 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> 결과를 포함하는 인스턴스입니다.
예외
예제
이 예제에서는 각 Customers 엔터티와 관련된 Orders 엔터티를 반환하고 루프를 사용하여 엔터티 페이지를 로드 Customers 하고 중첩된 while 루프를 사용하여 do…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 경우 관련 엔터티가 상태로 로드 Unchanged 되고 엔터티 간의 링크도 상태로 만들어집니다Unchanged.entityModified
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> 데이터 서비스에서 로드할 관련 엔터티의 다음 페이지를 나타내는 개체입니다.
반품
관련 엔터티 데이터의 다음 페이지를 포함하는 응답입니다.
예외
설명
상태 또는 Modified 상태인 경우 entity 관련 엔터티는 상태의 개체 Unchanged 로 로드되고 링크도 상태입니다Unchanged.Unchanged
상태에 있는 Deleted 경우 entity 관련 엔터티는 상태에 있는 Unchanged 링크와 함께 상태의 Deleted 개체로 로드됩니다.