如何在FluentNHibernate中创建复合UNIQUE约束? [英] How to create composite UNIQUE constraint in FluentNHibernate?

查看:139
本文介绍了如何在FluentNHibernate中创建复合UNIQUE约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以对单个属性 Map(x => x.GroupName).WithUniqueConstraint()

但是,如何在流利的nHibernate中创建一个复合唯一约束(其中唯一的约束是在两列的组合上操作的)? 在我使用的最新版本中,它是 UniqueKey(KeyName)就是这样。

  Map(x => x.Something).UniqueKey(KeyName); 
Map(x => x.SomeOtherThing).UniqueKey(KeyName);


I know that I can Map(x => x.GroupName).WithUniqueConstraint() for a single property.

But how do create a composite unique constraint in fluent nHibernate (where the unique constraint operates on the combination of two columns)?

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆