EF Core problem with Enum
Posted: Tue 15 Jun 2021 12:38
Hi
I'm having problems performing a query where the filter field is of type ENUM. In the database, this field is a char, where it stores the values (A, E, N) that correspond to the first letter of each item in it. However, the SQL generated by the handle and entire description of the item. Note that for SQLSERVER the problem is not presented.
Ex:
Entity
public Filter Filter { get; set; }
Map
builder.Property(e => e.Filter)
.IsRequired()
.HasColumnName("FILTER")
.HasMaxLength(1)
.IsUnicode(false)
.HasConversion(new EnumToCharConverter<Filter>());
This converter takes the first letter of the ENUM item, but is simply being ignored when using the Devart driver.
Enum
public enum Filter
{
Abs = 1,
Ext = 2,
Nen = 3,
}
Query generated
WHERE ("x".FILTER = 'Ext')
Query intended
WHERE ("x".FILTER = 'E')
Technical details
EfCore: 2.2
Driver Devart Version: 9.11.980.0
I'm having problems performing a query where the filter field is of type ENUM. In the database, this field is a char, where it stores the values (A, E, N) that correspond to the first letter of each item in it. However, the SQL generated by the handle and entire description of the item. Note that for SQLSERVER the problem is not presented.
Ex:
Entity
public Filter Filter { get; set; }
Map
builder.Property(e => e.Filter)
.IsRequired()
.HasColumnName("FILTER")
.HasMaxLength(1)
.IsUnicode(false)
.HasConversion(new EnumToCharConverter<Filter>());
This converter takes the first letter of the ENUM item, but is simply being ignored when using the Devart driver.
Enum
public enum Filter
{
Abs = 1,
Ext = 2,
Nen = 3,
}
Query generated
WHERE ("x".FILTER = 'Ext')
Query intended
WHERE ("x".FILTER = 'E')
Technical details
EfCore: 2.2
Driver Devart Version: 9.11.980.0