Due to my error message:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: Conversion failed when converting the nvarchar value 'AB' to data type int.
I have an enum with an AB value and I want to save it as integer not nvarchar value. I have an enum with flags attribute something like: [Flags]
public enum VisibleDayOfWeek : int
{
None = 0,
Monday = 1,
Tuesday = 2,
Wednesday = 4,
Thursday = 8,
Friday = 16,
Saturday = 32,
Sunday = 64
}
I can not save multiple day string in the db but I can save the sum of the flags values which represent multiple days.
I do not want to create an integer wrapper around these enum properties.
The underlying type of an enum is a byte or integer so why the heck is it saved as string/varchar? That makes no sense. Even the entity framework got it right with its enum support after years...
What is the solution in this case?
Seems this guy has the same problem: https://github.com/tapmantwo/enumflags