Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSP-9173 | Fix lease payment reports #4457

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions source/backend/dal/Repositories/LeasePaymentRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,10 @@ public IEnumerable<PimsLeasePayment> GetAllTracking(DateTime startDate, DateTime
return this.Context.PimsLeasePayments
.AsSplitQuery()
.Include(p => p.LeasePaymentCategoryTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.Lease)
.ThenInclude(p => p.PimsPropertyLeases)
.ThenInclude(p => p.Property)
.ThenInclude(p => p.PimsHistoricalFileNumbers)
.ThenInclude(h => h.HistoricalFileNumberTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.Lease)
.ThenInclude(p => p.RegionCodeNavigation)
.Include(p => p.LeasePeriod)
Comment on lines -50 to -59
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole query is a "tracking" query - but it is only used to generate a report (which is read-only).
Any considerations to add "AsNotTracking" to the query so EF is not tracking these entities wastefully?

.ThenInclude(t => t.Lease)
.ThenInclude(t => t.LeaseStatusTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.Lease)
.ThenInclude(t => t.LeasePayRvblTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.Lease)
.ThenInclude(t => t.PimsLeaseStakeholders)
.ThenInclude(t => t.Person)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.Lease)
.ThenInclude(t => t.LeaseProgramTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.Lease)
.ThenInclude(p => p.PimsLeaseLeasePurposes)
.ThenInclude(c => c.LeasePurposeTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.LeasePeriodStatusTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.LeasePmtFreqTypeCodeNavigation)
.Include(p => p.LeasePeriod)
.ThenInclude(t => t.Lease)
.ThenInclude(t => t.PimsLeasePeriods)
.ThenInclude(t => t.PimsLeasePayments)
.Where(p => p.PaymentReceivedDate <= endDate && p.PaymentReceivedDate >= startDate);
}
}
Expand Down
4 changes: 4 additions & 0 deletions source/backend/dal/Repositories/LeaseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public IEnumerable<PimsLease> GetAllByIds(IEnumerable<long> leaseIds)

IEnumerable<PimsLease> leases = this.Context.PimsLeases.AsSplitQuery().AsNoTracking()
.Include(l => l.PimsPropertyLeases)
.ThenInclude(p => p.Property)
.ThenInclude(p => p.PimsHistoricalFileNumbers)
.ThenInclude(h => h.HistoricalFileNumberTypeCodeNavigation)
.Include(l => l.RegionCodeNavigation)
.Include(l => l.LeaseProgramTypeCodeNavigation)
.Include(l => l.LeasePayRvblTypeCodeNavigation)
Expand All @@ -131,6 +134,7 @@ public IEnumerable<PimsLease> GetAllByIds(IEnumerable<long> leaseIds)
.ThenInclude(p => p.LeasePurposeTypeCodeNavigation)
.Include(l => l.LeaseStatusTypeCodeNavigation)
.Include(l => l.PimsLeaseStakeholders)
.ThenInclude(t => t.Person)
.Include(t => t.PimsPropertyImprovements)
.Include(l => l.PimsInsurances)
.Include(l => l.PimsSecurityDeposits)
Expand Down
Loading