开发者

ASP.net 4.0 Entity Data Model Mysql Not Treating Mysql Enums Right

I just starting learning, testing ADO.net Entity Data Models with MySql - everything is going fantastic except i've noticed one thing..

In my MySql table i've created an Enum column type. When ASP.net creates the Model classes the enums are treated as strings and not as Enums - is there a way to fix this?

UserStatus column in MySql is an Enum that has 2 potential properties, Enabled and Disabled - however asp.net treats as string value: user.UserStatus =开发者_运维技巧 "Enabled";

Was hoping to see something along these lines... user.UserStatus = UserStatuses.Enabled;

Thanks!!

Loren


There's no such thing as an enum sql type, at least not a standard type, which means it's non-standard and you'll have a hard time finding any framework that properly supports it properly.

To make matters worse, Entity Framework does not currently support Enum types in code either. There are some hacks and workarounds, but you will find them to be painful and not worth it. For all intents and purposes, a MySQL enum is a string object. You may have to issue some custom sql to get the enum types to populate your listbox though.

Oh, and FYI: 8 Reasons why MySQL's ENUM data type is evil

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜