Batching is a feature that facilitates sending HTTP requests in a batch so that the number of round trips to the server are reduced and the consumer of the data service's performance is increased. To use this feature, use a method called ExecuteBatch
that accepts one of more DataServiceRequest
instances as a parameter. Here is an example:
var dataServiceProxy = new PayrollDataContext(new Uri("http://localhost:1156/PayrollDataService.svc")); dataServiceProxy.MergeOption = MergeOption.AppendOnly; var employees = from emp in dataServiceProxy.Employee select emp; var employeesUri = new Uri(employees.ToString()); var departments = from dept in dataServiceProxy.Department select dept; var departmentsUri = new Uri(departments.ToString()); var result = dataServiceProxy.ExecuteBatch( new DataServiceRequest<Employee>(employeesUri), new DataServiceRequest<Department>(departmentsUri)); foreach (var r in result) { QueryOperationResponse...