Contact me!
Eric Håård
+46 (0) 73 375 86 06

Batch Calls

When using batching you must first register your requests to the AccessClient and then process the requests and finally get the results.

This model works nicely with the WebForms page life cycle and automatically processes registered requests just before PreRenderComplete. This gives that components can register requests on Page_Load and get the results in PreRenderComplete. If the component does not process PreRenderComplete youcan always hook up on the dataReady event. When registering requests, the request is tagged with a unique key which is used when getting the result.

Samlpe code AccessClient:

using(var client = new AccessClient())
{
   client.RegisterRequest("products", 
        new Expose.ListProducts2Request { set parameters });
   client.RegisterRequest("filters", 
        new Expose.ListProductFilters2Request { set parameters });

   client.ProcessRequests();

   ProductItemPagedList productList;
   FilterList filters = null;

   client.TryGet("products", out productList);
   client.TryGet("filters", out filters);
}

Sample code using repository (Enferno.Public.Web):

using(var batch = repository.GetBatch())
{
   batch.RegisterRequest("products", repository.Products.ListProductsRequest(...));
   batch.RegisterRequest("filters", repository.Products.ListProductFiltersRequest(...);

   batch.ProcessRequests();

   ProductItemPagedList productList;
   FilterList filters = null;

   batch.TryGet("products", out productList);
   batch.TryGet("filters", out filters);
}

Note: Batched requests are processed in parallel on the server and the results are guaranteed to be returned in the same order as the requests are passed in. However if more than one request affect the same data there is no guarantee that the order of execution is according to the order of the requests. So if request2 is processed before request1 then the result for request1 will have the most recent data.