本文整理汇总了C#中System.Data.Services.Client.DataServiceContext.EndExecute<TElement>方法的典型用法代码示例。如果您正苦于以下问题:C# DataServiceContext.EndExecute<TElement>方法的具体用法?C# DataServiceContext.EndExecute<TElement>怎么用?C# DataServiceContext.EndExecute<TElement>使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Services.Client.DataServiceContext
的用法示例。
在下文中一共展示了DataServiceContext.EndExecute<TElement>方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginExecuteCustomersQuery
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);
}
}
}