C# Enum using values in Sql Server table -


at moment have sql server 2005 table looks bit like:

 id | name  | desc ---------------------- 1  | 1   | value 1 3  | 3 | value 3 5  | 5  | value 5 

this table corresponds enum in c# looks like:

enum msgtypes{   <summary>value one</summary>   1 = 1,   <summary>value three</summary>   3 = 3,   <summary>value five</summary>   5 = 5 } 

so question this: there way associate enum sql table changes/additions values in table don't need manually made in c# code?

if want dynamic, why make enum start with? fetch details table on app startup, , remember them in (say) dictionary<int, string>. encapsulate value within own value type enforced range, if wanted to.

alternatively, if don't mind recompiling, fetch @ build time , autogenerate enum source code.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -