No items when projecting out groupings with a null key
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
Hello!
I have a code which I expect to return me 3 groups of items.
```C#
var spec = new EntitySpec();
var query = _repository.GetQuery(spec);
var result = await query
.GroupBy(x => (Guid?)x.Json.RootElement.GetProperty(property).GetGuid())
.Select(g => new { g.Key, Count = g.Count(), Items = g.ToList() })
.ToListAsync(cancellationToken);
```
It really returns me groups, but unfortunately the result is incomplete:
```json
[
{
"key": "d0005e8f-ebaa-481d-aabf-628b5d172c05",
"count": 2,
"items": [
"",
""
]
},
{
"key": "f6223371-aa16-4e51-94c7-f91af84b2200",
"count": 1,
"items": [
""
]
},
{
"key": null,
"count": 2,
"items": []
}
]
```
All the expected groups and their sizes are here, but for the last one with `null` key there are no items returned.
If I make a direct request to database it returns me expected data.
```sql
select count(*), "Json"::jsonb -> 'c41c88f5-fb3b-4b77-bc11-2df17e6312b9' as "keys"
from "Entities"
group by "Json"::jsonb -> 'c41c88f5-fb3b-4b77-bc11-2df17e6312b9'
```

### Provider and version information
EF Core version: **7.0.8**
Database provider: **Npgsql.EntityFrameworkCore.PostgreSQL**
Target framework: **.NET 6.0**
Operating system: **Any**
IDE: **Any**
Contributor guide
Assessment
This issue has not been assessed yet.