How to: Execute Queries in a Batch (WCF Data Services)

 

By using the WCF Data Services client library, you can execute more than one query against the data service in a single batch. For more information, see Batching Operations.

The example in this topic uses the Northwind sample data service and autogenerated client data service classes. This service and the client data classes are created when you complete the WCF Data Services quickstart.

The following example shows how to call the M:Microsoft.SqlServer.ReportingServices.ReportingService.ExecuteBatch method to execute an array of DataServiceRequest<TElement> objects that contains queries that return both Customers and Products objects from the Northwind data service. The collection of QueryOperationResponse<T> objects in the returned DataServiceResponse is enumerated, and the collection of objects contained in each QueryOperationResponse<T> is also enumerated.

[!CODE [Astoria Northwind Client#BatchQuery](../CodeSnippet/VS_Snippets_Misc/astoria northwind client#batchquery)]

WCF Data Services Client Library

Show: