如何在 FluentNHibernate 中创建复合 UNIQUE 约束? [英] How to create composite UNIQUE constraint in FluentNHibernate?
本文介绍了如何在 FluentNHibernate 中创建复合 UNIQUE 约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我可以为单个属性Map(x => x.GroupName).WithUniqueConstraint()
.
I know that I can Map(x => x.GroupName).WithUniqueConstraint()
for a single property.
但是如何在 fluent nHibernate 中创建复合唯一约束(唯一约束对两列的组合进行操作)?
But how do create a composite unique constraint in fluent nHibernate (where the unique constraint operates on the combination of two columns)?
推荐答案
在我使用的最新版本中,UniqueKey("KeyName")
就是这样做的.
In the latest version that I have used, it isUniqueKey("KeyName")
that does this.
Map(x => x.Something).UniqueKey("KeyName");
Map(x => x.SomeOtherThing).UniqueKey("KeyName");
这篇关于如何在 FluentNHibernate 中创建复合 UNIQUE 约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文