Here I’ll try to explain how we have used it in that application writing a new example.
As you can see it is a simple template just to suggest how organize your mapping… nothing complicated.
The DomainIn the assembly Acme.ModuleA
In the assembly Acme.ModuleB
Some extensionsJust to not forget it later…
The mappingYou can organize the mapping of your modules in a single assembly, in general the same where you are generating the session factory, or in more than one assembly. In general you need just a little class to map a module so please don’t be exaggerated separating your application.
For this example I will show three implementations of ModuleMapper all implemented in the same assembly named Acme.Persistence.Wiring.
The GeneralsPatternsModuleMapper register just part of my common convention for the current application. Then the mapping of my Acme.ModuleA:
The mapping of Acme.ModuleB:
The NHibernate’s initializationFirst you need a method to get all modules of your application, for simplicity here is a simple implementation:
and now you have all is needed to have the session factory:
In the line 5 I’m getting just one mapping document for the whole domain. You can use the method mapper.CompileMappingForEach without problems. The main matter here is the fact that I’m using just one instance of ObjectRelationalMapper and Mapper to give the whole picture of the domain of the application to ConfORM.