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