Where expression on nullable enum with value conversion generates invalid query

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
laurensb
Posts: 7
Joined: Thu 06 Jun 2019 07:44

Where expression on nullable enum with value conversion generates invalid query

Post by laurensb » Thu 06 Jun 2019 08:01

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

laurensb
Posts: 7
Joined: Thu 06 Jun 2019 07:44

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

Post by laurensb » Fri 07 Jun 2019 15:04

This issue is also present in version 9.7.770.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Mon 10 Jun 2019 18:20

Thank you for your report. We will provide the internal build with the fix as soon as possible.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Wed 03 Jul 2019 18:35

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Thu 04 Jul 2019 16:41

New build of dotConnect for Oracle 9.7.790 is available for download now: viewtopic.php?f=1&t=38981.

laurensb
Posts: 7
Joined: Thu 06 Jun 2019 07:44

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

Post by laurensb » Mon 15 Jul 2019 07:28

Thank you for the update. The fix seems to work.

Post Reply