views:

243

answers:

2

Can I mix fluent mapping with automapping? If yes how can it be done?

A: 

Just define your mappings and auto mappings ;-) I can't tell exact code since I don't have VS at hands, but you just follow FNH guidelines on creating both types of mapping and that's it, they should work together.

Here's example:

     AutoPersistenceModel mappings = AutoMap
         .AssemblyOf<Order>()
         .IgnoreBase<BaseEntity>()
         .Where(GetAutoMappingFilter)
         .Conventions.Setup(GetConventions())
         .Setup(GetSetup())
         .UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
     // this is for std mapping
    //mappings.AddMappingsFromAssembly(
    //        typeof(Northwind.Data.NHibernateMappings.RouteConditionMap).Assembly);

The last line is commented because I don't need std mappings.

However why would you need that? In automapping you can override the same things.

queen3
I would like to use fluent mappings on one property because of this http://stackoverflow.com/questions/1875466/auto-mapping-a-idictionarystring-myclass-with-fluent-nhibernate issue.
Marcus