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
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
im trying to do something with this now:
Unhandled exception rendering component: The LINQ expression 'DbSet<Employee>()
.OrderBy(e => e.EmpNo)
.Where(e => e.EmpNo > __lastId_0)
.Where(e => ___departmentService_1.GetDepartmentName(e.EmpNo) == __allowedDepartment_2)' could not be translated.
Unhandled exception rendering component: The LINQ expression 'DbSet<Employee>()
.OrderBy(e => e.EmpNo)
.Where(e => e.EmpNo > __lastId_0)
.Where(e => ___departmentService_1.GetDepartmentName(e.EmpNo) == __allowedDepartment_2)' could not be translated.
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
thanks
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
yeah, I did that and it works
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
also somehow this can't compare two chars, but can compare two strings, so when I convert gender char to string, first filter works
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
It would add complexity to this method, but ill try that
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
The LINQ expression 'DbSet<Employee>()
.OrderBy(e => e.EmpNo)
.Where(e => e.EmpNo > __lastId_0)
.Where(e => (int)e.Gender.get_Chars(0) == (int)__allowedGender_1)' could not be translated. Additional information: Translation of method 'string.get_Chars' failed. If this method can be mapped to your custom function, see
https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable',
'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
The LINQ expression 'DbSet<Employee>()
.OrderBy(e => e.EmpNo)
.Where(e => e.EmpNo > __lastId_0)
.Where(e => (int)e.Gender.get_Chars(0) == (int)__allowedGender_1)' could not be translated. Additional information: Translation of method 'string.get_Chars' failed. If this method can be mapped to your custom function, see
https://go.microsoft.com/fwlink/?linkid=2132413 for more information. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable',
'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
19 replies
CC#
Created by Sernik on 10/26/2022 in #help
Keyset pagination with filters
sorry for my english and thanks for help!
19 replies
CC#
Created by Sernik on 10/24/2022 in #help
Await Linq Expression
Thanks!
9 replies
CC#
Created by Sernik on 10/24/2022 in #help
Await Linq Expression
9 replies
CC#
Created by Sernik on 10/24/2022 in #help
Await Linq Expression
and this is also not working
9 replies
CC#
Created by Sernik on 10/24/2022 in #help
Await Linq Expression
9 replies
CC#
Created by Sernik on 10/24/2022 in #help
Await Linq Expression
this is not working
9 replies
CC#
Created by Sernik on 10/17/2022 in #help
Deserialize JSON to dynamic object without Newtonsoft.Json
wow, this is very cool, thanks
40 replies
CC#
Created by Sernik on 10/17/2022 in #help
Deserialize JSON to dynamic object without Newtonsoft.Json
Thanks for help guys!
40 replies