diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index d2c1f9fd..40d05ccb 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -90,42 +90,21 @@ namespace AyaNova.Biz //////////////////////////////////////////////////////////////////////////////////////////////// - /// GET - /// - /// - - internal async Task GetAsync(long fetchId, bool logTheGetEvent = true) + // GET + // + internal async Task GetAsync(long id, bool logTheGetEvent = true) { - /* - https://docs.microsoft.com/en-us/ef/core/querying/related-data - using (var context = new BloggingContext()) - { - var blogs = context.Blogs - .Include(blog => blog.Posts) - .ThenInclude(post => post.Author) - .ThenInclude(author => author.Photo) - .ToList(); - } -WARNING: Since version 3.0.0, each Include will cause an additional JOIN to be added to SQL queries produced by relational providers, whereas previous versions generated additional SQL queries. -This can significantly change the performance of your queries, for better or worse. -In particular, LINQ queries with an exceedingly high number of Include operators may need to be broken down into multiple separate LINQ queries in order to avoid the cartesian explosion problem. - */ - //This is simple so nothing more here, but often will be copying to a different output object or some other ops - //var ret = await ct.WorkOrder.SingleOrDefaultAsync(m => m.Id == fetchId); - - var ret = + //https://docs.microsoft.com/en-us/ef/core/querying/related-data + //docs say this will not query twice but will recognize the duplicate woitem bit which is required for multiple grandchild collections + var ret = await ct.WorkOrder .Include(w => w.WorkorderItems) - .ThenInclude(wi=>wi.WorkorderItemLabors) + .ThenInclude(wi => wi.WorkorderItemLabors) .Include(w => w.WorkorderItems) - .ThenInclude(wi=>wi.worko) - .SingleOrDefaultAsync(m => m.Id == fetchId); - + .ThenInclude(wi => wi.WorkorderItemParts) + .SingleOrDefaultAsync(m => m.Id == id); if (logTheGetEvent && ret != null) - { - //Log - await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, fetchId, BizType, AyaEvent.Retrieved), ct); - } + await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct); return ret; }