This commit is contained in:
@@ -363,10 +363,21 @@ namespace AyaNova.Biz
|
||||
{
|
||||
var batch = idList.Take(IReportAbleObject.REPORT_DATA_BATCH_SIZE);
|
||||
idList = idList.Skip(IReportAbleObject.REPORT_DATA_BATCH_SIZE).ToArray();
|
||||
|
||||
//query for this batch, comes back in db natural order unfortunately
|
||||
var batchResults = await ct.Customer.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
||||
|
||||
|
||||
//order the results back into original
|
||||
//What is happening here:
|
||||
//for performance the query is batching a bunch at once by fetching a block of items from the sql server
|
||||
//however it's returning in db order which is often not the order the id list is in
|
||||
//so it needs to be sorted back into the same order as the ide list
|
||||
//This would not be necessary if just fetching each one at a time individually (like in workorder get report data)
|
||||
|
||||
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||
|
||||
|
||||
foreach (Customer w in orderedList)
|
||||
{
|
||||
await PopulateVizFields(w);
|
||||
|
||||
Reference in New Issue
Block a user