I have a foreach loop which sends WCF request as below:
foreach (var rec in LstPRSCRPTActivated)
{
var OrderItemQueryActivated = GV.dbContext.Load(GV.dbContext.GetOrdritemsQuery((int)rec.PresNo));
OrderItemQueryActivated.Completed += new EventHandler(OrderItemQueryActivated_Completed);
}
In the WCF data services, I have the following code:
public IQueryable<OrderItem> GetOrdritems(int PresNo)
{
return this.ObjectContext.OrderItems.Where(o => o.ScriptNo == PresNo);
}
If the second query takes less time than the first, in the call back event OrderItemQueryActivated_Completed, I get the results from the second query and then gets the results from the first query. But I dont want to happen this way. I want to get the results of first query first followed by the second. Is there a way to do this using some kind of a wait in the service?
Is it possible to create a composite service call that does all of the operations in a single call? If not, you can parallel invoke all of the operations and wait until they’re done to get the result.