Open janseris opened 2 years ago
Problematic query:
ss.Set<Level1>()
.Where(l1 => l1.Id == 1)
.SelectMany(e => e.OneToMany_Optional1)
.Where(l2 => l2.Date == new DateTime(2012, 12, 12))
.SelectMany(e => e.OneToMany_Optional2.First().OneToMany_Optional3)
.Where(l4 => l4.Name == "L4 01")
issue is First followed by collection in from clause Work-around
ss.Set<Level1>()
.Where(l1 => l1.Id == 1)
.SelectMany(e => e.OneToMany_Optional1)
.Where(l2 => l2.Date == new DateTime(2012, 12, 12))
.SelectMany(e => e.OneToMany_Optional2.First().OneToMany_Optional3.Where(l4 => l4.Name == "L4 01"))
Moving Where after SelectMany inside makes it work.
Hi I have a problem with a query. Executing a query which seems OK produces ArgumentException with a message which doesn't tell anything about the error. I spent approximately 1 hour localising the error and it is in the query itself.
The problem is that I need to use the broken query because I explicitly need only WORKFLOW from the first SADA_WORKFLOW to force 1 to 1 relation constraint (note: I am using DB-First), not from all SADA_WORKFLOW enities! The second query which works, does not force the 1 to 1 relation.
Is there, please, any way to achieve desired results from the query?
Data model:
Dictionary: Workflow = workflow configuration for a system module for a project (finite automaton) Sada workflow = a reusable/shared collection of workflows Stavebni Objekt = building Projekt = project Konfigurace projektu = project configuration Typ x = a type/kind of x
Please see the following comparison:
The difference is:
Sample project and database here: The project assumes that the database is loaded as
EFCore6QueryArgumentException
on.\SQLEXPRESS
(local named SQL Server Express instance).issue.zip
Running the "broken" query produces this exception:
Repro video:
https://user-images.githubusercontent.com/64279914/164792695-83111d50-3eb2-4dec-a11f-cde1047c71b2.mp4
Exception details:
System info: Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.2.0 Preview 4.0 Windows 10 Home 21H1 Host (useful for support): Version: 6.0.4 Commit: be98e88c76 Microsoft.EntityFrameworkCore.SqlServer 6.0.4 EFCorePowerTools 2.5.918