C#C
C#3y ago
17 replies
Argonak

✅ Linq 'nullable objects must have value' error source

I'm attempting to build up a query but I'm having issues with this group by.
When I try to perform
.ToListAsync()
I get the desired results but for further code reasons
.CountAsync()
needs to also be functional but I keep getting this error.

-The TenantId is a nullable field but in the database there is 0 records where it's actually null.
-In this screenshot I'm setting the whole group
g.ToList()
but in reality I only need access to the Name field and TenantId, pre-encountering this it was
g.Select(x => x.Name).ToList()


I have tried quite a few things but can't seem get rid of the error, even knowing the source of the problem would be helpful.
Error.JPG
Was this page helpful?