DataServiceContext.EndExecute<TElement>(IAsyncResult) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
öğesini tamamlamak BeginExecute<TElement>(Uri, AsyncCallback, Object)için çağrıldı.
public:
generic <typename TElement>
System::Collections::Generic::IEnumerable<TElement> ^ EndExecute(IAsyncResult ^ asyncResult);
public System.Collections.Generic.IEnumerable<TElement> EndExecute<TElement> (IAsyncResult asyncResult);
member this.EndExecute : IAsyncResult -> seq<'Element>
Public Function EndExecute(Of TElement) (asyncResult As IAsyncResult) As IEnumerable(Of TElement)
Tür Parametreleri
- TElement
Sorgu tarafından döndürülen tür.
Parametreler
- asyncResult
- IAsyncResult
IAsyncResult Nesne.
Döndürülenler
Sorgu işlemi tarafından döndürülen sonuçlar.
Özel durumlar
olduğunda asyncResult
null
.
Bu DataServiceContext örnekten kaynaklanmadığındaasyncResult
.
-veya-
Yöntemi EndExecute<TElement>(IAsyncResult) daha önce çağrıldı.
İsteğin yürütülmesi sırasında veya yanıt iletisinin içeriğini nesnelere dönüştürdüğünde bir hata oluştuğunda.
Örnekler
Aşağıdaki örnekte, sorguyu başlatmak için yöntemini çağırarak zaman uyumsuz bir sorgunun BeginExecute nasıl yürütüldiği gösterilmektedir. Satır içi temsilci sorgu sonuçlarını görüntülemek için yöntemini çağırır EndExecute . Bu örnekteDataServiceContext, WCF Veri Hizmetleri tamamladığınızda oluşturulan Northwind veri hizmetini temel alan Hizmet Başvurusu Ekleme aracı tarafından oluşturulan kullanılır.
public static void BeginExecuteCustomersQuery()
{
// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);
// Define the query to execute asynchronously that returns
// all customers with their respective orders.
DataServiceQuery<Customer> query = (DataServiceQuery<Customer>)(from cust in context.Customers.Expand("Orders")
where cust.CustomerID == "ALFKI"
select cust);
try
{
// Begin query execution, supplying a method to handle the response
// and the original query object to maintain state in the callback.
query.BeginExecute(OnCustomersQueryComplete, query);
}
catch (DataServiceQueryException ex)
{
throw new ApplicationException(
"An error occurred during query execution.", ex);
}
}
// Handle the query callback.
private static void OnCustomersQueryComplete(IAsyncResult result)
{
// Get the original query from the result.
DataServiceQuery<Customer> query =
result as DataServiceQuery<Customer>;
foreach (Customer customer in query.EndExecute(result))
{
Console.WriteLine("Customer Name: {0}", customer.CompanyName);
foreach (Order order in customer.Orders)
{
Console.WriteLine("Order #: {0} - Freight $: {1}",
order.OrderID, order.Freight);
}
}
}
Public Shared Sub BeginExecuteCustomersQuery()
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)
' Define the delegate to callback into the process
Dim callback As AsyncCallback = AddressOf OnCustomersQueryComplete
' Define the query to execute asynchronously that returns
' all customers with their respective orders.
Dim query As DataServiceQuery(Of Customer) = _
context.Customers.Expand("Orders")
Try
' Begin query execution, supplying a method to handle the response
' and the original query object to maintain state in the callback.
query.BeginExecute(callback, query)
Catch ex As DataServiceQueryException
Throw New ApplicationException( _
"An error occurred during query execution.", ex)
End Try
End Sub
' Handle the query callback.
Private Shared Sub OnCustomersQueryComplete(ByVal result As IAsyncResult)
' Get the original query from the result.
Dim query As DataServiceQuery(Of Customer) = _
CType(result.AsyncState, DataServiceQuery(Of Customer))
' Complete the query execution.
For Each customer As Customer In query.EndExecute(result)
Console.WriteLine("Customer Name: {0}", customer.CompanyName)
For Each order As Order In customer.Orders
Console.WriteLine("Order #: {0} - Freight $: {1}", _
order.OrderID, order.Freight)
Next
Next
End Sub
Açıklamalar
Standart başlangıç-bitiş zaman uyumsuz desenine göre, sorgu sonuçları alındığında sağlanan geri çağırma çağrılır. Daha fazla bilgi için bkz. Zaman Uyumsuz İşlemler.
Geri arama çağrıldığında, tüm sonuçlar HTTP akışından okunur, ancak işlenmez; hiçbir yerel kullanıcıya yönelik nesne gerçekleşmedi veya değiştirilmedi ve kimlik çözümlemesi gerçekleşmedi. Çağrıldığında EndExecute , bir DataServiceResponse oluşturulur ve döndürülür, ancak sonuçlar yine de işlenmemiştir. Kimlik çözümlemesi, nesne gerçekleştirme ve işleme yalnızca kullanıcı sonuçları numaralandırdığında gerçekleşir.
Şunlara uygulanır
Ayrıca bkz.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin