Sernik
Sernik
Explore posts from servers
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
it probably has horrible efficiency, but it works 😄
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
Wow, it works, thanks!
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
nevermind, it's worst linq i have ever seen and it does't even work
if (_appState.DepartmentFilter.GetAllowedValue(out var allowedDepartment))
{
employees = employees.Where(e =>
(e.DeptEmps.MaxBy(de => de.ToDate) != null &&
e.DeptEmps.MaxBy(de => de.ToDate)!.DeptNoNavigation.DeptName == allowedDepartment)
|| (e.DeptManagers.MaxBy(dm => dm.ToDate) != null &&
e.DeptManagers.MaxBy(dm => dm.ToDate)!.DeptNoNavigation.DeptName == allowedDepartment));
}
if (_appState.DepartmentFilter.GetAllowedValue(out var allowedDepartment))
{
employees = employees.Where(e =>
(e.DeptEmps.MaxBy(de => de.ToDate) != null &&
e.DeptEmps.MaxBy(de => de.ToDate)!.DeptNoNavigation.DeptName == allowedDepartment)
|| (e.DeptManagers.MaxBy(dm => dm.ToDate) != null &&
e.DeptManagers.MaxBy(dm => dm.ToDate)!.DeptNoNavigation.DeptName == allowedDepartment));
}
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
wait a minute, i have an idea...
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
One solution is to first query and get a dictionary of all departments for you employees collection and do a dictionary lookup instead of using GetDepartmentName
Is there any better way to do this? I don't want to store in memory, for example 20 000 salary records
19 replies