Page 1 of 1

Where expression on nullable enum with value conversion generates invalid query

Posted: Thu 06 Jun 2019 08:01
by laurensb
Similar to the issue in this post: viewtopic.php?f=30&t=38205&p=134188#p134188 but for nullable enums.

When using EFCore value conversions for nullable enum properties and performing a comparison in a where clause, Devart ignores the value expression and generates a query using the numeric value of the enum.

When using a non-nullable enum value, it works. E.g.:

Code: Select all

dbContext
    .Set<Rider>()
    .Where(_ => _.Mount == EquineBeast.Mule)
    .ToList();
However, when using making the enum property nullable, it generates an incompatible query (ORA-01722: invalid number):

Code: Select all

dbContext
    .Set<Rider>()
    .Where(_ => _.Mount != null && _.Mount.Value == EquineBeast.Mule)
    .ToList();
will generate the following SQL statement

Code: Select all

SELECT "_".ID,
       "_".MOUNT
FROM RIDER "_"
WHERE ("_".MOUNT IS NOT NULL)
  AND ("_".MOUNT = 1) /* This should be "_".MOUNT = 'Mule' */
Database Provider: Devart.Data.Oracle.EFCore version 9.7.734

A repository reproducing the issue can be found here: https://github.com/LBRitsSES/devart-efc ... -bug-repro

Re: Where expression on nullable enum with value conversion generates invalid query

Posted: Fri 07 Jun 2019 15:04
by laurensb
This issue is also present in version 9.7.770.

Re: Where expression on nullable enum with value conversion generates invalid query

Posted: Mon 10 Jun 2019 18:20
by Shalex
Thank you for your report. We will provide the internal build with the fix as soon as possible.

Re: Where expression on nullable enum with value conversion generates invalid query

Posted: Wed 03 Jul 2019 18:35
by Shalex
The bug with applying a filter to the nullable property with implicit EnumToStringConverter via LINQ queries in EF Core 2 is fixed.

The internal build with the fix: https://www.devart.com/pub/nuget_oracle_9_7_787.zip.

Re: Where expression on nullable enum with value conversion generates invalid query

Posted: Thu 04 Jul 2019 16:41
by Shalex
New build of dotConnect for Oracle 9.7.790 is available for download now: viewtopic.php?f=1&t=38981.

Re: Where expression on nullable enum with value conversion generates invalid query

Posted: Mon 15 Jul 2019 07:28
by laurensb
Thank you for the update. The fix seems to work.