0

I have two tables

EnumType(EnumTypeID,Name,Description)

EnumTypeValue(EnumTypeValueId,Name,Value,EnumTypeID) 

EnumTypeValue references EnumType.

General Idea is something like I want to Create Enums for all Values in EnumType table and for each Enum its values will be corresponding values in EnumTypeValue table. Suppose I have row in EnumType(1,Gender,some description) and corresponding to it in EnumTypeValue i have two rows (1) 1,Male,5,1 (2)2,Female,6,1 .I want to create dynamically, public enum Gender {Male = 5,Female=6} so that i could use it in code as enum. There are going to be many such enums as the project will progress. All I want, just run particular code and all the enums will be generated.

I am using EntityFramework for DB interaction.Any help will be highly APPERICIATED.

Josh
  • 44,706
  • 7
  • 102
  • 124
yo chauhan
  • 12,079
  • 4
  • 39
  • 58

1 Answers1

3

You'll probably end up having to write some T4 to generate them. Check out:

T4 template to Generate Enums

Community
  • 1
  • 1
eouw0o83hf
  • 9,438
  • 5
  • 53
  • 75