Reputation: 495
Can anyone tell me how to correctly get ORMLite to store enums as integers? I know that this was not supported in 2012 but i found code for some unit tests that suggest it should work now but it doesn't. When we try the column gets created as a varchar(max) in ms sql. We currently use a wrapping property that is ignored to convert the enum value to int but then you can't use it for queries etc so it is less than ideal.
Upvotes: 3
Views: 926
Reputation: 143374
Add a [Flags]
attribute to enums you want ServiceStack to treat as integers.
From v4.0.54 you can also use the [EnumAsInt]
attribute which will save the enum as an int
in OrmLite but still serialize it as a string.
Upvotes: 5