oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
413 stars 191 forks source link

EF Core: Wrong SQL generated for negated InExpression for large Enumeration #276

Closed arne-imhof-oasis closed 1 year ago

arne-imhof-oasis commented 1 year ago

Given int[] manyValues = Enumerable.Range(0, 1001).ToArray(); , context.Foo.Where(f => !manyValues.Contains(f.Bar))… wrongly generates …WHERE "Bar" NOT IN (…1000 values…) OR "Bar" NOT IN (…1 value…) while context.Foo.Where(f => manyValues.Contains(f.Bar))… correctly generates …WHERE "Bar" IN (…1000 values…) OR "Bar" IN (…1 value…) The current implementation wrongly always chooses 'OR' even for the negated case, but should simply choose 'AND' in this case.

As a local workaround, create a custom QuerySqlGenerator + Factory and fixup VisitIn. Use EF Core's ReplaceService to patch it in.

alexkeh commented 1 year ago

Which EF Core version, Oracle EF Core version, and DB version are you using?

Do you have a simple, complete test case we can use to reproduce the problem?

arne-imhof-oasis commented 1 year ago

Check ouf assembly Oracle.EntityFrameworkCore in version

The (admittedly sketchy) notes in my initial issue should be enough to get you going.

alexkeh commented 1 year ago

I created a bug (35047863) to track the issue and have the Oracle EF Core dev team review.

alexkeh commented 1 year ago

This bug has been fixed. I expect it will be available in the Oracle EF Core 21.12 patch.

alexkeh commented 1 year ago

The bug fix was able to get merged into 21.11. So, it will be delivered sooner.