Replace lazy loading with eager loading
This commit is contained in:
parent
852b079428
commit
237b178107
@ -76,14 +76,13 @@ namespace MarcoBMS.Services.Helpers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<EmployeeVM> result = new List<EmployeeVM>();
|
List<EmployeeVM> result = new List<EmployeeVM>();
|
||||||
if (ProjectId != null)
|
if (ProjectId.HasValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
result = await (from pa in _context.ProjectAllocations.Where(c => c.ProjectId == ProjectId)
|
result = await _context.ProjectAllocations
|
||||||
join em in _context.Employees.Where(c => c.TenantId == TenentId && c.IsActive == true).Include(fp => fp.JobRole) // Include Feature
|
.Include(pa => pa.Employee)
|
||||||
on pa.EmployeeId equals em.Id
|
.Where(c => c.ProjectId == ProjectId.Value && c.IsActive && c.Employee != null)
|
||||||
select em.ToEmployeeVMFromEmployee()
|
.Select(pa => pa.Employee!.ToEmployeeVMFromEmployee())
|
||||||
)
|
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user