This commit is contained in:
2020-05-07 19:56:48 +00:00
parent d131d16d17
commit a40cda4043

View File

@@ -90,42 +90,21 @@ namespace AyaNova.Biz
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
/// GET // GET
/// //
/// internal async Task<WorkOrder> GetAsync(long id, bool logTheGetEvent = true)
internal async Task<WorkOrder> GetAsync(long fetchId, bool logTheGetEvent = true)
{ {
/* //https://docs.microsoft.com/en-us/ef/core/querying/related-data
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
using (var context = new BloggingContext()) var ret =
{
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 =
await ct.WorkOrder await ct.WorkOrder
.Include(w => w.WorkorderItems) .Include(w => w.WorkorderItems)
.ThenInclude(wi=>wi.WorkorderItemLabors) .ThenInclude(wi => wi.WorkorderItemLabors)
.Include(w => w.WorkorderItems) .Include(w => w.WorkorderItems)
.ThenInclude(wi=>wi.worko) .ThenInclude(wi => wi.WorkorderItemParts)
.SingleOrDefaultAsync(m => m.Id == fetchId); .SingleOrDefaultAsync(m => m.Id == id);
if (logTheGetEvent && ret != null) if (logTheGetEvent && ret != null)
{ await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
//Log
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, fetchId, BizType, AyaEvent.Retrieved), ct);
}
return ret; return ret;
} }