开发者

ASP.NET MVC with NHibernate

开发者 https://www.devze.com 2022-12-13 13:05 出处:网络
I want to know few 开发者_如何转开发things about ASP.NET MVC with NHibernate. Is NHibernate the best ORM used with ASP.NET MVC?

I want to know few 开发者_如何转开发things about ASP.NET MVC with NHibernate.

  1. Is NHibernate the best ORM used with ASP.NET MVC?
  2. If so, will NHibernate slow down the application?
  3. What can be done to improve performance of an ASP.NET MVC application with NHibernate?


  1. Depends. If you are a total newbie you might want to try entity framework because it contains all the ORM designer classes that allows you to create entity class by drag and drop.
  2. No, it won't. NHibernate is used by a lot of sites, and it has first and second level caching feature that would speed things up by caching the previous operation, so performance isn't really an issue.
  3. You can only improve your app after you identify the bottleneck. Don't premature optimize.


I use NHibernate with ASP.NET MVC for GarageCommerce.com and it is very fast even on pretty low budget hardware. The overhead of NHibernate is negligible compared to the raw cost of talking to a database.

There is a strong community, proven patterns to follow and support tools like NHibernate Profiler. It's likely that you would end up with a more efficient application than if you had rolled your own database access.

You have a better chance of solving scalability issues with a powerful tool like NH. You can turn on it's 2nd level cache and back it with memcache. There is also work on NHiberate.Shards to help you horizontally partition your data.


  1. There is no best ORM to use with ASP.NET MVC. The best ORM is the one which meets your needs.
  2. No, there is nothing inherent in NHibernate that will slow down your application.
  3. Don't worry so much about performance unless it becomes a problem in the future. Is there a good reason why you have such high performance requirements?


Michael, nHibernate is great for CRUD operations and handling of complex operations on business objects. Though it can handle rather complex queries, when it comes to reporting, I'd stick to Crystal reports... and if you have lots of stored procedures, no ORM likes them too much.


just curious...we use crystal reports for our web-based reporting environment...heavy, complex stored procedures that tie up the db for a long time then exporting to pdf.

does converting to an html based solution using an ORM like NHibernate make sense there? seems like there's more flexibility in terms of performance tweaks?

0

精彩评论

暂无评论...
验证码 换一张
取 消