-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Milestone
Description
Hi, everyone.
When I try to select nested JSON collection with the following config:
modelBuilder.Entity<EntityMain>()
.OwnsMany(e => e.Inner, b => b.OwnsMany(e => e.Values, b2 => b2.ToTable(table)).ToJson("inner").ToTable(table))
.ToTable(table);Query:
dbContext.Set<EntityMain>().AsNoTracking().Select(c =>
c.Inner!.Where(c => c.Key == "Asd")
.Select(c => new NamedTimeSeriesEntry { Key = c.Key, Values = c.Values.Where(v => v.Date <= new DateTime(2022, 3, 1)).ToList() }))
.ToListAsync().Result;When query splitting is on (UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery)) I get the following exception:
System.AggregateException: 'One or more errors occurred. (The given key 'Property: TimeSeriesEntry.NamedTimeSeriesEntryId (no field, int) Shadow Required PK FK AfterSave:Throw' was not present in the dictionary.)'
When I turn query splitting off it works fine. It seems that query splitting should not be used for JSON entities.
Any workarounds for now?
Minimum repro included.
Json-Nested-Collection-Query-minirepro.zip
EF Core version: 8.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer 8.0.0, Npgsql.EntityFrameworkCore.PostgreSQL 8.0.0
Target framework: .NET 8.0
Operating system: Windows
Reactions are currently unavailable