开发者

multiple unique keys in nhibernate

开发者 https://www.devze.com 2023-01-22 13:40 出处:网络
I need constr开发者_StackOverflow中文版aints created in the following manner: CONSTRAINT [IX_Unique_1] UNIQUE NONCLUSTERED

I need constr开发者_StackOverflow中文版aints created in the following manner:

CONSTRAINT [IX_Unique_1] UNIQUE NONCLUSTERED 
(
    [Ordering] ASC,
    [Description] ASC
),
CONSTRAINT [IX_Unique_2] UNIQUE NONCLUSTERED 
(
    [Description] ASC
)

I have the following nHibernate mapping:

<property name="Description" column="Description" type="String" unique-key="IX_Seed_Template_Fields_Result" />

<property name="Ordering" column="Ordering" type="Int32" unique-key="IX_Seed_Template_Fields_Result" />

So how can I add a separate unique constraint just for the Description column?


If you don't care about the index names in the database, you can map it like this:

<property 
  name="Description" 
  column="Description" 
  type="String" 
  unique-key="Description, Ordering_Description" />

<property 
  name="Ordering" 
  column="Ordering" 
  type="Int32" 
  unique-key="Ordering_Description" />

you can provide a comma separated list of index names. All columns which have the same name in the list are added to the same index.


Use <database-object> to create additional indexes.

5.6. Auxiliary Database Objects

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号