0

I need to define a unique constraint on multiple properties. In XML this would look like:

<properties name="Name" unique="true">
  <property name="FirstName" />
  <property name="LastName" />
</properties>

What is the mapping-by-code equivalent in NHibernate (3.3+)? Are there any alternatives to create a multi-column unique index?

Thomas Luzat
  • 710
  • 7
  • 21

1 Answers1

0

An alternative way to create a unique index is the following:

this.Property(x => x.FirstName, m => m.UniqueKey("name"));
this.Property(x => x.LastName, m => m.UniqueKey("name"));

I still have not found out how to map <properties>, though.

Thomas Luzat
  • 710
  • 7
  • 21