【发布时间】:2016-02-08 19:20:31
【问题描述】:
我知道我可以Map(x => x.GroupName).WithUniqueConstraint() 获取单个属性。
但是如何在 fluent nHibernate 中创建复合唯一约束(其中唯一约束对两列的组合进行操作)?
【问题讨论】:
标签: nhibernate fluent-nhibernate nhibernate-mapping
我知道我可以Map(x => x.GroupName).WithUniqueConstraint() 获取单个属性。
但是如何在 fluent nHibernate 中创建复合唯一约束(其中唯一约束对两列的组合进行操作)?
【问题讨论】:
标签: nhibernate fluent-nhibernate nhibernate-mapping
在我使用的最新版本中,是UniqueKey("KeyName")这样做的。
Map(x => x.Something).UniqueKey("KeyName");
Map(x => x.SomeOtherThing).UniqueKey("KeyName");
【讨论】:
在映射文件中使用SetAttribute,如下所示:
Map(x => x.Something).SetAttribute("unique-key", "someKey");
Map(x => x.SomeOtherThing).SetAttribute("unique-key", "someKey");
【讨论】: