SQLMetal and Enum Types
-
I'm using the DataContext's GetTable method to populate data. The Mapping is done as a type/class which was created from my database through an automated process using SQLMetal.exe. By default SQLMetal will create classes with properties, with types such as integer/byte for smallint and tinyiny fields, and string for char fields etc. I'd like these properties to have their proper enumerated types. For example, the Position field in my database is a tinyint, created like follow:
<Column(Storage:="_Position", DbType:="TinyInt")> _
Public Property Position() As Byte
Get .......But I'd like the property to be
<Column(Storage:="_Position", DbType:="TinyInt")> _
Public Property Position() As UserPositions
Get .......Where UserPositions is delcared as:
Public Enum UserPositions
None = 0
Cashier = 1
Supervisor = 2
Manager = 3
Clerk = 4
Other = 99
End EnumNow, when I manually change the above, everything work beautifully, but my automated process keeps on overwriting this. Seeing that these are all partial classes, I could try and do something in a separate file, but have no idea where to start. I also thought about inheriting from this class and overloading the properties, but this would be an issue since I would need to change the return types. Does anyone have any ideas?