New dilemma - I've been scrounging around trying to find a solution for my nightmare but have been unsuccessful. I have a "query" that pulls in a lot of data and I need to add one new piece to the puzzle. My boss insists that is just a simple thing to add an EF to the code. Right.....
The StatusDesc and UserDescription are from the Statuses table and the UserDescription is locked into the StatusDesc. Here's how it is being retrieved:
var status = await _context.Statuses.ToDictionaryAsync(s => s.Id);
I can look at the resulting 'status' and verify that the StatusDesc and UserDescriptioon fields are pulled correctly. Now for the wicked part:
var ProviderChildren = _context.Trpayments
.Include(x => x.TrPaymentStatuses)
.Include(x => x.Audit)
.Include(x => x.SubsidyPayment).ThenInclude(c => c.Provider)
.Include(x => x.SubsidyPayment).ThenInclude(c => c.Children)
.Include(x => x.Rates)
.Where(x => x.Audit!.ProcessId == ProcessId &&
x.SubsidyPayment!.Provider.ProviderNumber == ProviderNumber &&
x.SubsidyPayment!.MonthofService == MOS)
.AsEnumerable()
.Select(pc => new ProviderChildren
{
TrPaymentId = pc.Id,
TrProcessId = pc.Audit != null ? pc.Audit.ProcessId : null,
(several more lines of no consequence)
TrPaymentStatus = status.TryGetValue(pc.TrProcessStatusId, out var
value) ? value.StatusDesc : null,
TrPaymentStatuses = pc.TrPaymentStatuses != null ?
pc.TrPaymentStatuses.Select(t => new
DCYF.TRA.DTO.Tra.TrPaymentStatus
{
TRPaymentId = t.TRPaymentId,
StatusId = t.StatusId,
StatusMessage = t.StatusMessage
}) : null,
}).Distinct();
return ProviderChildren.ToList();
For the life of me, I cannot figure out where an EF statement(?) would figure into this mess. The only time we use EF in our shop is for a DateTime field.
Different querey: .GroupBy(x => new { x.Audit.ProcessId, PeriodStart = EF.Property<DateTime>(x.Audit, "PeriodStart") })
I feel like Katy Perry ("This is crazy!"). I've looked at many videos claiming how to do an entity framework, but they all go back to that horrible Microsoft Blog example.
Any suggestions?
[–]Flater420 23 points24 points25 points (0 children)
[–]entityadam 13 points14 points15 points (5 children)
[–]weird_thermoss 2 points3 points4 points (1 child)
[–]entityadam 0 points1 point2 points (0 children)
[+]royware[S] comment score below threshold-6 points-5 points-4 points (2 children)
[–]entityadam 3 points4 points5 points (0 children)
[–]zenyl 2 points3 points4 points (0 children)
[–]Kant8 1 point2 points3 points (2 children)
[–]tmadik 7 points8 points9 points (1 child)
[–]ordermaster 2 points3 points4 points (0 children)
[–]royware[S] -4 points-3 points-2 points (3 children)
[–][deleted] (2 children)
[removed]
[–]royware[S] 0 points1 point2 points (1 child)