on 12-03-2018 7:08 AM
Hi,
I am doing batch operations for requesting multiple queries. I am using Service Layer SSO with UI-API and using the UI-API SBO_Application object to get the Service Layer B1SESSION and ROUTEID cookies.
**************************************************************************************
Here is the below code:
Uri uriBps = new Uri(_StrServiceLayerUrl + "/BusinessPartners?$select=CardCode&$top=1");
Uri uriItems = new Uri(_StrServiceLayerUrl + "/Items?$select=ItemCode&$top=1");
DataServiceRequest[] batchRes = new DataServiceRequest[2];
batchRes[0] = new DataServiceRequest<BusinessPartner>(uriBps);
batchRes[1] = new DataServiceRequest<Item>(uriItems);
BatchRequest(batchRes);
************************************************************************************
public static void BatchRequest(DataServiceRequest[] batchRequests)
{
try
{
DataServiceResponse batchResponse = null;
serviceLayer.MergeOption = MergeOption.AppendOnly;
//Batch for querying data from server, to use: ExecuteBatch
batchResponse = serviceLayer.ExecuteBatch(batchRequests);
//Use the same way to get results
foreach (QueryOperationResponse res in batchResponse)
{
//Attention, for each QueryOperationResponse in the batchResponse, it only fall into one kind of collection.
//So each time, only one kind of type-cast will succeeded.
//BusinessPartner
try
{
foreach (BusinessPartner bp in res.Cast<BusinessPartner>())
{
// Do the action you want to show BusinessPartner details
}
}
catch (Exception)
{
//throw;
}
//Item
try
{
foreach (Item it in res.Cast<Item>())
{
// Do the action you want to show Item details
}
}
catch (Exception)
{
//throw;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
**************************************************************************************
When I am trying to fetching the response its giving me the error :
Only a single enumeration is supported by this IEnumerable
Kindly help me.
Thanks & Regards.
Manish
User | Count |
---|---|
91 | |
10 | |
10 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.