开发者

How to get enum value names from int column in SQL Server database for a .NET class

I am trying to query an int column which represents an enum in a .NET class. I want the result of the query to be the name of the int value. Please keep in mind that I am not trying to do this through .NET code, just work开发者_Python百科ing with plain SQL queries here.

I could create another table with these values and their corresponding names and then join with it to get the desired result but that would mean having to maintain the values.

Is there any other on-the-fly solution I can use?


you should just be able to call myEnum.ToString()

i guess to start from the beginning:

int dbValue = 1;
var myEnum = (myEnumType)dbValue;
string enumName = myEnum.ToString();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜