Map data objects that I don't know when I do BuildSessionFactory!
Hello to all
I'm new using NHibernate and FluentHibernate and I'm evaluating this tool to use in the software house that I work.
We have a simple requirement that I can't match with FluentHibernate. We want to use the AutoMap or FluentMapping feature but when the application start we don't know what objects need to be mapped.
Our application work with modules and we only know what modules will be loaded after consult the database (for that we need database connection working).
Each module is responsible for their own data and have their own Domain classes. If they need to access any other data, they must use the Business Layer responsible for the data. Each module is a self-contain class library to be integrated in any other application like Web, WPF, Win32, etc.
As you can see, in the begin of the application we don't know all the entity classes to be load. Of couse we can use the HBN files, but for that we need to force the module developers to generate that and for now it's not an alternative. Would be an alternative if we can configure per module a mapping folder insted of all mapping files going to the same folder in the root of the application.
After saying all this, how can I add mapping rules after calling the BuildSessionFactory method? If this is not possible how can I resolve this problem? How can I instruct the FluentHibernate to load a new configuration?
Hope you can help me!
I can do this with EntityFramework and will be a long cut back if I couldn't do with NHibernate / Fluent
Regards
Paulo Aboim Pinto
Odivelas - Portugal
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by James Gregory on 17 Mar, 2010 09:49 AM
You can't modify a session factory after creating it, this is by design in NHibernate. You could re-create the session factory, but that'll mean you take the performance hit of doing that again.
I would recommend querying your database for your modules with a regular ADO query, skip an ORM for it entirely.
How exactly can you do this with EntityFramework? It was my understanding that, similar to NHibernate, the configuration is immutable once created.
3 Posted by Paulo Aboim Pinto on 18 Mar, 2010 01:17 AM
I was wrong about what EF does. What I was doing was create a new Model in each module.
the solution that I get is, create a ISession, get all the modules of the application and create another ISession with all the MapFile loaded.
tkx all
Regards
Paulo Aboim Pinto
Odivelas - Portugal
James Gregory resolved this discussion on 16 May, 2010 05:48 PM.