Page 1 of 1

Expression with enum value not converted correctly to SQL

Posted: Thu 03 Jun 2021 15:31
by HL00
Hi, I'm using the Devart Oracle provider with EF Core 5. I generate a Linq expression in code and execute it using the EntityQueryProvider.

This is the DebugView of the Expression.

Code: Select all

.Call System.Linq.Queryable.First(
    .Extension<Microsoft.EntityFrameworkCore.Query.QueryRootExpression>,
    '(.Lambda #Lambda1<System.Func`2[DB.SomeTable,System.Boolean]>))

.Lambda #Lambda1<System.Func`2[DB.SomeTable,System.Boolean]>(DB.SomeTable $x) {
    (System.Nullable`1[System.Int32]).If ($x.Status == "0") {
        .Constant<System.Nullable`1[DB.StatusEnum]>(EnumVal0)
    } .Else {
        .If ($x.Status == "1") {
            .Constant<System.Nullable`1[DB.StatusEnum]>(EnumVal1)
        } .Else {
            .If ($x.Status == "2") {
                .Constant<System.Nullable`1[DB.StatusEnum]>(EnumVal2)
            } .Else {
                null
            }
        }
    } == (System.Nullable`1[System.Int32]).Constant<DB.StatusEnum>(EnumVal1)
}

This gets translated into a query with the following where statement:

Code: Select all

WHERE CASE
	  WHEN "t".STATUS = N'0' THEN 0
	  WHEN "t".STATUS = N'1' THEN 1
	  WHEN "t".STATUS = N'2' THEN 2
	  ELSE NULL
END = EnumVal1
Which crashes Oracle because it doesn't recognize "EnumVal1". I expected this to get translated since the enum values on the left hand of the expression are converted, but it fails to. Since this functionality did work for us on EF6, I assume it is an issue with Devart (or EF Core?), but if there's any ways of solving/circumventing this from my end I would love to hear.

Re: Expression with enum value not converted correctly to SQL

Posted: Mon 07 Jun 2021 07:54
by Shalex
Could you please send us a small test project with the corresponding DDL/DML script for reproducing the issue?

Re: Expression with enum value not converted correctly to SQL

Posted: Mon 07 Jun 2021 08:04
by Shalex
Make sure that the problem persists with the newest build v9.14.1273.

Re: Expression with enum value not converted correctly to SQL

Posted: Tue 08 Jun 2021 11:49
by HL00
Yes, the issue still persists in v9.14.1273.

I've send a small test project through the contact form

Re: Expression with enum value not converted correctly to SQL

Posted: Fri 11 Jun 2021 17:59
by Shalex
HL00 wrote: Tue 08 Jun 2021 11:49 Yes, the issue still persists in v9.14.1273.

I've send a small test project through the contact form
Sorry, but we didn't receive your test project. We have just sent the credentials for accessing our FTP server to your email used when registering on the forum.

Re: Expression with enum value not converted correctly to SQL

Posted: Mon 14 Jun 2021 07:37
by HL00
Ah, I was wondering why the contact form said the request was succesful but I never got a confirmation mail. I've uploaded the files to the FTP server as "EnumOracleCrashDemo.zip"

Re: Expression with enum value not converted correctly to SQL

Posted: Mon 14 Jun 2021 18:19
by Shalex
HL00 wrote: Mon 14 Jun 2021 07:37 Ah, I was wondering why the contact form said the request was succesful but I never got a confirmation mail.
We have initiated an internal investigation to find out the reason why your original ticket was not submitted.
HL00 wrote: Mon 14 Jun 2021 07:37I've uploaded the files to the FTP server as "EnumOracleCrashDemo.zip"
Thank you for the test project. We have reproduced the issue and will notify you when it is fixed.

Re: Expression with enum value not converted correctly to SQL

Posted: Tue 15 Jun 2021 07:34
by HL00
Shalex wrote: Mon 14 Jun 2021 18:19 We have initiated an internal investigation to find out the reason why your original ticket was not submitted.
If it helps, I was using chrome without addons. In addition, the first time I attempted to submit it, it crashed entirely with some vague error message I don't remember. The second time I didn't do anything different and it seemed to work. I also remember I filled out that I'm a licensed user but did not enter my license number
Shalex wrote: Mon 14 Jun 2021 18:19 Thank you for the test project. We have reproduced the issue and will notify you when it is fixed.
Great to hear, thanks!

Re: Expression with enum value not converted correctly to SQL

Posted: Tue 22 Jun 2021 10:37
by Shalex
The bug with comparing enum values in EF Core 3 and EF Core 5 is fixed. We will notify you when a new public build is available for download.

Re: Expression with enum value not converted correctly to SQL

Posted: Wed 23 Jun 2021 12:03
by HL00
That's great to hear! Thanks

Re: Expression with enum value not converted correctly to SQL

Posted: Fri 09 Jul 2021 09:07
by Shalex
New build of dotConnect for Oracle 9.14.1298 is available for download now: viewtopic.php?f=1&t=47244.