DataServiceContext.LoadProperty Yöntem

Tanım

Veri hizmetinden ertelenen içeriği yükler.

Aşırı Yüklemeler

Name Description
LoadProperty(Object, String)

Veri hizmetinden belirtilen bir özellik için ertelenen içeriği yükler.

LoadProperty(Object, String, DataServiceQueryContinuation)

Sağlanan sorgu devamlılık nesnesini kullanarak veri hizmetinden ilgili varlıkların sonraki sayfasını yükler.

LoadProperty(Object, String, Uri)

Sağlanan sonraki bağlantı URI'sini kullanarak ilgili varlıkların bir sayfasını yükler.

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

Sağlanan genel sorgu devamlılığı nesnesini kullanarak veri hizmetinden ilgili varlıkların sonraki sayfasını yükler.

LoadProperty(Object, String)

Veri hizmetinden belirtilen bir özellik için ertelenen içeriği yükler.

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

Parametreler

entity
Object

Yüklenecek özelliği içeren varlık.

propertyName
String

Yüklenecek belirtilen varlığın özelliğinin adı.

Döndürülenler

Yükleme işlemine verilen yanıt.

Örnekler

Aşağıdaki örnekte, döndürülen Customers her örnekle ilgili nesnenin Orders açıkça nasıl yüklendiği gösterilmektedir. Bu örnekte DataServiceContext , WCF Veri Hizmetleri'ni tamamladığınızda oluşturulan Northwind veri hizmetini temel alan Hizmet Başvurusu Ekle aracı tarafından oluşturulan kullanılır.

// 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

Açıklamalar

Bu yöntemin çağrılması, özellik değerini getirmek için bir ağ işlemi çağırır. Belirtilen özellik, ilişkilendirmeleri veya bağlantıları temsil eden özellikler de dahil olmak üzere varlık üzerindeki özelliklerden herhangi biri olabilir.

özelliği bir ilişkilendirmeyi, bağlantıyı veya ertelenmiş özelliği temsil ediyorsa, bu yöntemin çağrılması istemciye ilgili kaynakları rahatça yüklemek için bir yol sağlar.

Varlık değişmemiş veya değiştirilmiş durumdaysa, özellik değeri ilgili varlıkları yükler ve değişmemiş bağlantılarla değişmeden işaretler

Özellik zaten yüklüyse, bu yöntemin çağrılması özelliğin değerini yenilemenize olanak tanır.

Şunlara uygulanır

LoadProperty(Object, String, DataServiceQueryContinuation)

Sağlanan sorgu devamlılık nesnesini kullanarak veri hizmetinden ilgili varlıkların sonraki sayfasını yükler.

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

Parametreler

entity
Object

Yüklenecek özelliği içeren varlık.

propertyName
String

Yüklenecek belirtilen varlığın özelliğinin adı.

continuation
DataServiceQueryContinuation

DataServiceQueryContinuation<T> Veri hizmetinden yüklenecek ilgili varlıkların sonraki sayfasını temsil eden nesne.

Döndürülenler

İlgili varlık verilerinin sonraki sayfasını içeren yanıt.

Özel durumlar

veya entity durumunda olduğunda.DetachedAdded

Açıklamalar

Veya entity durumundayken UnchangedModified, ilgili varlıklar bir durumda nesneler Unchanged olarak yüklenir ve bağlantılar da Unchanged durumda olur.

Bir durumda olduğunda entityDeleted, ilgili varlıklar durumundaki bağlantılar Unchanged ile bir Deleted durumda nesneler olarak yüklenir.

Şunlara uygulanır

LoadProperty(Object, String, Uri)

Sağlanan sonraki bağlantı URI'sini kullanarak ilgili varlıkların bir sayfasını yükler.

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

Parametreler

entity
Object

Yüklenecek özelliği içeren varlık.

propertyName
String

Yüklenecek belirtilen varlığın özelliğinin adı.

nextLinkUri
Uri

Sonraki sonuçlar sayfasını yüklemek için kullanılan URI.

Döndürülenler

İsteğin QueryOperationResponse<T> sonuçlarını içeren örneği.

Özel durumlar

Veya entity durumunda Detached olduğundaAdded.

Örnekler

Bu örnek, her varlıkla ilgili Orders varlıkları döndürür ve varlık sayfalarını yüklemek Customers için bir do…while döngü ve veri hizmetinden ilgili Customers varlıkların sayfalarını yüklemek için iç içe while döngü kullanır.Orders LoadProperty yöntemi, ilgili Orders varlıkların sayfalarını yüklemek için kullanılır.

// 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

Açıklamalar

Veya entity durumundayken UnchangedModified, ilgili varlıklar duruma yüklenir Unchanged ve varlıklar arasındaki bağlantılar da bir Unchanged durumda oluşturulur.

Bir durumdayken entityDeleted , ilgili varlıklar duruma yüklenir Unchanged ve varlıklar arasındaki bağlantılar durumunda oluşturulur Deleted .

Ayrıca bkz.

Şunlara uygulanır

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

Sağlanan genel sorgu devamlılığı nesnesini kullanarak veri hizmetinden ilgili varlıkların sonraki sayfasını yükler.

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ür Parametreleri

T

Yüklenecek koleksiyonun öğe türü.

Parametreler

entity
Object

Yüklenecek özelliği içeren varlık.

propertyName
String

Yüklenecek belirtilen varlığın özelliğinin adı.

continuation
DataServiceQueryContinuation<T>

DataServiceQueryContinuation<T> Veri hizmetinden yüklenecek ilgili varlıkların sonraki sayfasını temsil eden nesne.

Döndürülenler

İlgili varlık verilerinin sonraki sayfasını içeren yanıt.

Özel durumlar

veya entity durumunda olduğunda.DetachedAdded

Açıklamalar

Veya entity durumundayken UnchangedModified, ilgili varlıklar bir durumda nesneler Unchanged olarak yüklenir ve bağlantılar da Unchanged durumda olur.

Bir durumda olduğunda entityDeleted, ilgili varlıklar durumundaki bağlantılar Unchanged ile bir Deleted durumda nesneler olarak yüklenir.

Şunlara uygulanır