views:

79

answers:

1

If using Fluent NHibernate, is it possible to automap most classes, but specify that a couple of particular classes should be mapped using the regular fluent API rather than being automapped? And if so, can anyone point me to some sample code that shows how to do it?

Thanks!

+1  A: 

It is possible and easy to mix-up mapping configurations:

var cfg = Fluently.Configure()
    .Database(configurer)
    .Mappings(map =>
                  {
                      // Automapping
                      map.AutoMappings.Add(AutoMap.Assemblies(Assembly.GetExecutingAssembly())
                                             .Where(type => type.Namespace == typeof(Domain.Market.Share).Namespace)
                                             .Where(type => type.Namespace == typeof(Domain.HR.Employee).Namespace));

                      // Fluent mappings
                      map.FluentMappings.AddFromAssemblyOf<Domain.Client.Macys>();
                  });

Good luck. ;-)

Rafael Belliard
Thanks Rafael, that does look easy!
PhantomDrummer