This commit is contained in:
@@ -341,7 +341,6 @@ namespace AyaNova.Biz
|
||||
//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
|
||||
@@ -350,7 +349,7 @@ namespace AyaNova.Biz
|
||||
//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;
|
||||
|
||||
batchResults = null;
|
||||
|
||||
foreach (Customer w in orderedList)
|
||||
{
|
||||
@@ -361,17 +360,34 @@ namespace AyaNova.Biz
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
ReportData.Add(jo);
|
||||
}
|
||||
orderedList = null;
|
||||
}
|
||||
vc.Clear();
|
||||
return ReportData;
|
||||
}
|
||||
|
||||
//populate viz fields from provided object
|
||||
private async Task PopulateVizFields(Customer o)
|
||||
{
|
||||
|
||||
if (o.HeadOfficeId != null)
|
||||
o.HeadOfficeViz = await ct.HeadOffice.AsNoTracking().Where(x => x.Id == o.HeadOfficeId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
{
|
||||
if (!vc.Has("headoffice", o.HeadOfficeId))
|
||||
{
|
||||
vc.Add(await ct.HeadOffice.AsNoTracking().Where(x => x.Id == o.HeadOfficeId).Select(x => x.Name).FirstOrDefaultAsync(), "headoffice", o.HeadOfficeId);
|
||||
}
|
||||
o.HeadOfficeViz = vc.Get("headoffice", o.HeadOfficeId);
|
||||
}
|
||||
|
||||
|
||||
if (o.ContractId != null)
|
||||
o.ContractViz = await ct.Contract.AsNoTracking().Where(x => x.Id == o.ContractId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
{
|
||||
if (!vc.Has("contract", o.ContractId))
|
||||
{
|
||||
vc.Add(await ct.Contract.AsNoTracking().Where(x => x.Id == o.ContractId).Select(x => x.Name).FirstOrDefaultAsync(), "contract", o.ContractId);
|
||||
}
|
||||
o.ContractViz = vc.Get("contract", o.ContractId);
|
||||
}
|
||||
|
||||
//Too slow and complex for EF Core
|
||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||
@@ -396,6 +412,9 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
//request cache for viz fields
|
||||
private VizCache vc = new VizCache();
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORT EXPORT
|
||||
|
||||
Reference in New Issue
Block a user