I would say that NHibernate is impressive at first glance and seems very difficult to learn. Therefore, by quickly reading an introductory document of 260 pages, and insisting on the tasks that I need to complete in test applications, NHibernate really fits. And if you're not fascinated by the XML mapping files, just use FluentNHibernate , which allows you to use OOP to map business domain objects.
In addition, if you are not completely free at NHibernate and prefer to go the other way, Enterprise Library 4.1 (October 2008) can either be a useful tool. Depending on the situation, in some organizations I chose the hybrid approach NHibernate - Enterprise Library. The data access application block (DAAB) in the corporate library is fairly easy to learn and does not require you to learn anything, but what you already know. You just need to know which object to use to create your DbConnection from the DatabaseProviderFactory class to read from your configuration files, and you can specify the default database.
As for my problems, I often use both NHibernate with the Enterprise Library. DAAB allows me, for example, to specify a database connection for each configuration file, since I prefer to parameterize only one connection per file. This allows me not to deploy unnecessary configuration files for configurations that have not changed at all, and only deploy a new configuration file for another connection. So, if you combine a new module that needs to connect somewhere else to another data warehouse, you create your module without worrying about everything else, update your software using the module DLL along with this new DAAB configuration file.
As for NHibernate, it’s important not to get rid of ISessionFactory when you no longer need it. This is an expensive instance, so you want to keep it in memory. However, you can serialize your class of configuration objects (like Serializable), so your application can build its configuration only if something has changed in your NHibernate configuration file. Again, I suggest you use the default hibernate.cfg.xml configuration file for NHibernate, so you won’t have to deploy the app.config file again and again when updates appear.
Hope this helps! Let me know if you need more information.
source share