Expression with enum value not converted correctly to SQL
Posted: Thu 03 Jun 2021 15:31
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.
This gets translated into a query with the following where statement:
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.
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