Question: Unique() constraint that allow NULLS ?
There is an interesting situation when is needed that a UNIQUE CONSTRAINT to take into account a WHERE clause. eg for SQL Server 2008:
CREATE UNIQUE NONCLUSTERED INDEX idx_yourcolumn_notnull
ON YourTable(yourcolumn)
WHERE yourcolumn IS NOT NULL;
There is a topic on StackOverflow regards this situation :
http://stackoverflow.com/questions/767657/how-do-i-create-a-unique-constraint-that-also-allows-nulls
So I'm wondering if there is some way of acheiving conditional unique constrains with fluent nhibernate.
If I understand correctly, you create an index, and then Sql Server uses it internally to speed up a query or filter results. Seems to me that filter does not affect mapping from db tables to objects.
Hey Guys,
Is it possible you can configure the FluentNHibernate Map with .UniqueKey("idx_name") but also tell it not to generate any SQL?
I have the same situation as @cristian-eriomenco in that I want a unique that allows nulls.
If I add the UniqueKey("idx_name") in the map, we forget and later generate a SQL column with a unique constraint incorrectly.
If you remove UniqueKey("idx_name") it prevents our FluentValidation working.
Is there a solution/workaround to this?