Ormlite int based enums coming as varchar (max)

Can anyone tell me how to properly get ORMLite to store enums as integers? I know this was not supported in 2012, but I found code for some unit tests that suggests it should work now, but it doesn't. When we try, the column is created as varchar (max) in ms sql. We are currently using the wrapping property, which is ignored, to convert the enum value to int, but then you cannot use it for queries etc., so it is less than ideal.

+3


source to share


1 answer


Add an attribute [Flags]

for the enumerations you want the ServiceStack to treat as integers.



From version 4.0.54 you can also use an attribute [EnumAsInt]

that will keep the enum as int

in OrmLite but still serialize it as a string.

+5


source







All Articles