One of my datagrid tables is working x100 times slower than the others(takes 15 seconds to load 5 records out of 120 with lazy loading). In my service layer I return the records like this:
users = personRepository.GetAll()
.GroupBy(g => g.PersonId)
.Select(a => a.FirstOrDefault())
.Join(personRepository.GetAll(),
m => m.PersonId,
m => m.PersonId,
(state1, state2) => new { state1, state2})
.GroupBy(g => g.state2.PersonId)
.Select(a => a.OrderByDescending(t => t.state2.Date).FirstOrDefault())
.OrderByDescending(o => o.state2.Id)
.Select(s => new UsersSG()
{//***********ATTENTION***********
state1= s.state1,
state2= s.state2
});
In the part with "ATTENTION" written, I map the anonymous type's properties to my viewmodel's virtual properties but I'm not sure if this breaks the lazy loading or not. Corresponding viewmodel is defined like this:
public virtual AkrKisiDurum state1 { get; set; }
public virtual AkrKisiDurum state2 { get; set; }
After I return the IQueryable list, I apply filtering, order by and paging to the query just like my other tables and return the result to view. I reviewed the generated query and nothing fancy appears in that.