ponies

Will NHibernate attempt to save the same object twice in this scenario?

Lets say I have two entities: Stable, and Pony. Stable has an IList<Pony> with a HasMany mapping configured with Cascade.All(). That means that if I do session.Save(myStable), each Pony in the collection will be saved. However, what happens if I do this? Pony myLittlePony = new Pony(Color.Brown); Stable myStable = new Stable(WoodType...

Can't catch exception thrown by Invoke on a compiled expression

In the class: private Func<T, object> pony; In my function: object newValue; try { newValue = pony.Invoke(model as T); // This is the line where I get an exception! } catch (Exception exception) { // This code is never run, even though I get an exception two lines up! if(exception is DivideByZeroException) throw new DivideByZer...

How do I use the IHasManyConvention Fluent NHibernate convention to set the PropertyRef on a HasMany mapping?

Currently I'm using Fluent NHibernate to generate my database schema, but I want the entities in a HasMany relationship to point to a different column for the reference. IE, this is what NHibernate will generate in the creation DDL: alter table `Pony` add index (Stable_ID), add constraint Ponies_Stable foreign key (Stable_Id) references...

How to look up an NHibernate entity's table mapping from the type of the entity?

Once I've mapped my domain in NHibernate, how can I reverse lookup those mappings somewhere else in my code? Example: The entity Pony is mapped to a table named "AAZF1203" for some reason. (Stupid legacy database table names!) I want to find out that table name from the NH mappings using only the typeof(Pony) because I have to write a ...