query:
context.Gears
.OrderBy(g => g.Nickname)
.Where(g => !g.HasSoulPatch && g.Weapons.Distinct().Last().IsAutomatic)
throws:
Expression of type 'System.Func`2[Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel.Gear,System.Collections.Generic.IEnumerable`1[System.Boolean]]' cannot be used for parameter of type 'System.Func`2[Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel.Gear,System.Boolean]' of method 'System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel.Gear] _Where[Gear](System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel.Gear], System.Func`2[Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel.Gear,System.Boolean])'
This happens because in ResultOperatorHandler.HandleLast we push last below select (needed so that we don't track unnecessary elements). However, if last is in a subquery, rather than being the final result operator this changes cardinality of that subquery, which leads to the exception.
query:
throws:
This happens because in ResultOperatorHandler.HandleLast we push last below select (needed so that we don't track unnecessary elements). However, if last is in a subquery, rather than being the final result operator this changes cardinality of that subquery, which leads to the exception.