i'm building a 3 tier wpf application. i heard that nhibernate is best for web applications.
i know how to use nhibernate.
should i use it or not??
are there any recommended or mappers that will be more suitable?
i'm building a 3 tier wpf application. i heard that nhibernate is best for web applications.
i know how to use nhibernate.
should i use it or not??
are there any recommended or mappers that will be more suitable?
NHibernate with Fluent NHibernate seems like a very nice ORM combination, with Fluent really getting rid of the tedious XML config stuff.
I will not venture into saying that it is the best solution or not, but several other ORMs require you to maintain external configuration files which really breaks useful things like refactoring.
That said, whether it is suitable for use in WPF applications vs web applications: usually, web applications have a more constrained process model than Windows clients. So if NHibernate is suitable for web apps, imo it should be more than suitable for Windows clients. They are statefull and have access to more memory and cpu power.
Even more, if you are building a 3-tier application, that is data access and business logic runs on a server, perhaps you access these tiers via web services which is only another form of web application.
Perhaps if you could elaborate on what you "heard" about NHibernate being only suitable for web apps we could understand more.
You can certainly use it, but you need to be very careful about how you manage your sessions (do not keep one session open for the duration of your application) and, in particular, how you use lazy initialization (make sure you look into detached objects, otherwise you're likely to find yourself faced with a LazyInitializationException and no obvious way to fix it).
It would be fair to say that you can get into trouble with NHibernate if you don't spend the time to understand how it works. That said, the learning curve starts very shallow but ramps up fairly significantly for some of the advanced features.
I would recommend taking a look at:
Of course, if you are only doing basic ORM operations then take a look at ActiveRecord. It's built on top of NHiberate, but does away with any mapping requirements - you just decorate your objects with attributes.
NHibernate isn't tied to any particular environment. You can just as easily use it in a WinForms/WPF application as you can a web app. Just be conscious of your session management, but that's something you should do regardless of environment.
If you ask the question this way the answer is DO NOT USE IT (as any other ORM). NHibernate is few steps behind the origin and even this is not an issue. The main issue is that ORMs cannot solve impedance mismatch problem in principle. It may make your life easier but it depends on your project (i wouldn't think this is the case).
I'd better concentrate on classic client/server scheme for better understanding how the things work. You need to know (at least) limitations of C/S architecture before you start using any ORM.
Start designing your application without knowing the solution you'll use for data persistence. It will be rock solid.