开发者

How to use NHibernate with asp.net 3.5

开发者 https://www.devze.com 2023-01-13 15:53 出处:网络
I want to use NHibernate with Asp.net 3.5 but i don\'t know how to use it.I search on Google but couldn\'t find the complete开发者_运维知识库 explanation about why to use NHibernate,Advantages of usi

I want to use NHibernate with Asp.net 3.5 but i don't know how to use it.I search on Google but couldn't find the complete开发者_运维知识库 explanation about why to use NHibernate,Advantages of using it and integration with Asp.net projects.


I would suggest checking out Castle and NHibernate. I recently started using it and was blown away with what it can do. Castle manages all your sessions for you. Also it is easy to use LINQ with it.

Check out
http://davidhayden.com/blog/dave/archive/2008/04/28/NHibernateCastleActiveRecordTutorialUninitiated.aspx

Another great tool to use (Should work with ASP.Net) is the Nhibernate Profiler http://nhprof.com/ It shows you what queries are being generated and the time its taking to run.

Also if you already have your database created you can download this tool http://www.agilityfororms.com/Home/Products/AfoCastleActiveRecordModelCodeGenerator/ It will create your models based on your database. Its works great for the most part. Although you have to register to download the free version still worth checking out.

Fluent NHibernate is supposed to be good as well although I have no experience with it. Might be worth checking out. http://fluentnhibernate.org/


You could have a look at this :

http://www.codegod.de/WebAppCodeGod/nhibernate-tutorial-1---and-aspnet-AID25.aspx

And this :

http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx


I'm nearing completion of my first project with it, and I've had mixed results. For basic data persistence, and assuming you already knew how to use it, it's much faster to build an application with it. You don't really have to worry about building stored procs and differentiating between new objects and updated objects.

On the other hand, until you're quite comfortable with it, it can take a long time to do something that would have been simple before. I've had a couple of problems, and it has been difficult and time consuming finding solutions to them.

To be fair, I've only written small applications with it and it has made the development process more difficult than I would consider required. The pain of using it is fairly similar from one app to the next, the benefits scale...


The best place to look is at NHibernate Forge. There's Blogs, wikis and groups that will help you out.

As for advantages of using it that is something you need to workout for yourself. Is it more advantageous than LinqToSql or Entity Framework? It depends on the project size and what you are actually looking for.

0

精彩评论

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

关注公众号