efcore: On Query cases: Microsoft.EntityFrameworkCore.dll: 'Value cannot be null.'
Repro repository https://github.com/Jonatthu/efcore-examples
On line 120 of program.cs and line 130 as well.
// Is not working
county = dbContext.User
.Select(lambda)
.Where(x =>
new []{ 44, 5, 546, 99 }.Contains(x.Blogs.Count())
)
.ToList();
The first 2 examples are workarounds but only will generate more request to the database, it should work with the examples below those.
I have included console logs for the queries that are being generated. The repro should work as soon as you clone it a hit f5 on vscode or vs. 😃
Exception has occurred: CLR/System.ArgumentNullException
Exception thrown: 'System.ArgumentNullException' in Microsoft.EntityFrameworkCore.dll: 'Value cannot be null.'
at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at ConsoleApp4.Program.Main(String[] args) in /Users/jonatthu/Documents/Jonatthu/efcore-examples/ConsoleApp4/Program.cs:line 121
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (9 by maintainers)
It can be done using single query.
Which should generate SQL like