我有两个单独的表。
[users] [ roles ]
+-----+ +-------+
| id | |user_id|
+-----+ +-------+
| value | <- [Represented by the enum]
+-------+
以及他们的模型。
class User { int id; IList<Roles> Roles; }
enum Roles { Worker, Manager, Director }
如您所见,它是简单的“一对多”。用户有很多角色。如何在 XML 中映射这些模型?
最佳答案
你的 map 怎么样? 你有没有试过这样的事情:
HasMany(x => x.Roles)
.Cascade.All()
.Table("UserRoles")
.Element("RolesEnum");
关于c# - 如何在与 NHibernate 的一对多关系中映射枚举?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17422806/