Created
November 28, 2012 21:40
-
-
Save randyburden/4164775 to your computer and use it in GitHub Desktop.
NHibernate Duplicate Mapping Problem Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
NHibernate now has the BeforeBindMapping event which gives you access to the object representation of the HBM XML files at runtime. | |
Use the BeforeBindMapping event to gain access to the object representation of the .HBM XML files. | |
This event allows you to modify any properties at runtime before the NHibernate Session Factory is created. This also makes the FluentNHibernate-equivalent convention unnecessary. Unfortunately there is currently no official documentation around this really great feature. | |
Here's a global solution to duplicate mapping problems ( Just remember that all HQL queries will now need to use Fully Qualified Type names instead of just the class names ). | |
*/ | |
var configuration = new NHibernate.Cfg.Configuration(); | |
configuration.BeforeBindMapping += (sender, args) => args.Mapping.autoimport = false; | |
// The functional equivalent in Fluent NHibernate would be this: | |
.Mappings( | |
m => | |
{ | |
m.FluentMappings.Conventions.Setup( x => x.Add( AutoImport.Never() ) ); | |
} ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment