Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. SQLMetal and Enum Types

SQLMetal and Enum Types

Scheduled Pinned Locked Moved LINQ
databasehelptutorialquestion
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hrodberaht
    wrote on last edited by
    #1

    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 Enum

    Now, 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?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups