Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fluent NHibernate: Mixing Automapping and manual mapping

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!

like image 313
LondonPhantom Avatar asked Aug 20 '10 10:08

LondonPhantom


1 Answers

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 == typeof(Domain.Market.Share))
                                             .Where(type => type == typeof(Domain.HR.Employee)));

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

Good luck. ;-)

like image 83
rebelliard Avatar answered Sep 21 '22 16:09

rebelliard