views:

346

answers:

1

This is a Fluent NHibernate newbie question, so bear with me.

I have a set of classes, and I'm applying the Automapping capabilities to it.

But I need to mark one of the properties of one of the techniques with a Unique constraint.

In the Fluent Wiki, it says

Sometimes it's necessary to make slight changes to a specific entity, without wishing to affect anything else; you can do that with the with Override method.

.Override(map => {
map.HasMany(x => x.Products) .Cascade.All(); });

But I can't figure out what object to apply the .Override method to.

Right now, I have

AutoPersistenceModel returnModel = AutoMap.AssemblyOf()

But the AutoPersistenceModel object does not have an Override method.

Can someone give me some simple sample code to walk me through this, or point me to some links with some examples?

Thanks.

+2  A: 

It does have an Override method in the 1.0 RTM. You use it like this:

AutoMap.AssemblyOf<Person>().Override<Shelf>(map =>
{
    map.HasMany(x => x.Products).Cascade.All();
});
Darin Dimitrov
Hmm. The FluentNHibernate dll that I am referencing has a Product Version of 1.0.0.0, but the Intellisense sure doesn't show an Override method. If I force it in anyway and try to build it I get an error that "...AutoPersistenceModel does not contain a definition for Override..."
Dave Hanna
You need to double check that you have the correct version of the assembly. I downloaded it from http://fluentnhibernate.org/downloads/releases/fluentnhibernate-1.0RTM.zip and the AutoPersistenceModel class definitely has the Override method. It also has Version=1.0.0.593 instead of 1.0.0.0
Darin Dimitrov
My apologies. You are correct. I had the 1.0RC version, not the 1.0RTM. Thanks for your help.
Dave Hanna

related questions