EF Code-First - 存储 IEnumerable 的枚举
我正在使用 EF June CTP,它具有简单的枚举支持。我有一个 MVC 3 视图,其中有一些复选框,提交时会作为某些枚举的数组进行检索。
public enum CheckBox : byte
{
VALUE_1 = 1,
VALUE_2 = 2,
...
}
我需要获取枚举集合 ((IEnumerable)) 并通过代码优先方法存储它。现在,该属性完全被忽略了。
我不确定它最终是否会在工作时创建一个单独的一对多表或将所有值存储在一列中,但任何想法都会很棒。只需要存储它。一旦它存储它,如果它不创建一个单独的一对多表并以某种方式将其与某些分隔字符串存储在同一个表中,那么最终会很棒,但我可能会到达这里。
谢谢。
更新1 尝试将 [Flags] 添加到枚举中但无济于事。在表生成过程中它被完全忽略。我的模型属性是:
public IEnumerable<CheckBox> Values { get; set; }
I'm using EF June CTP which has simple enum support. I have a MVC 3 view which has checkboxes that when submitted are retrieved as an array of some enum.
public enum CheckBox : byte
{
VALUE_1 = 1,
VALUE_2 = 2,
...
}
I need to take that colelction of enums ((IEnumerable)) and store that via code-first approach. Right now, that property is being ignored altogether.
I'm not sure if it would ultimately, when works, would create a separate one-to-many table or store all the values in one column but any ideas would be great. Just need to store it. Once it stores it, it would be ultimately be awesome if it didn't create a separate one-to-many table and somehow store it within the same table as some delimited string but I'm reaching here probably.
Thank you.
UPDATE 1
Tried adding [Flags] to the enum to no avail. It gets completely ignored during table generation. My Model property is:
public IEnumerable<CheckBox> Values { get; set; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用
[Flags]
枚举而不是集合:You should use a
[Flags]
enum instead of a collection: