Code: Select all
// Since my first post was deleted by some reason, I am posting it once again
LINQ:
Code: Select all
var result = dbContext.Set<Record>().Select(x => x.EnumValue ?? SomeEnum.One).ToList();
Code: Select all
SELECT COALESCE(r.enum_int_column, One)
FROM records AS r
Code: Select all
Unknown column 'One' in 'field list'
But, when Enum value is being used as a conditional value - it works fine.
LINQ
Code: Select all
dbContext.Set<Record>().Select(x => x.EnumValue == SomeEnum.One ? true : false).ToList()
Code: Select all
SELECT (CASE
WHEN r.enum_int_column = 1 THEN 1
ELSE 0
END)
FROM records AS r
Combining both expressions still produces invalid SQL.
LINQ:
Code: Select all
var result = dbContext.Set<Record>().Select(x => x.EnumValue == SomeEnum.Zero ? SomeEnum.One : x.EnumValue).ToList();
Code: Select all
SELECT (CASE
WHEN r.enum_int_column = 0 THEN One
ELSE r.enum_int_column
END)
FROM records AS r
The same SQL erros as an result
Code: Select all
Unknown column 'One' in 'field list'
https://github.com/Toshik/devart-mysql-bug-enums.git