linq to entities vs fluent nhibernate vs linq to s

2019-07-21 02:39发布

问题:

I have to build a website for a news channel..

Please help me decide which technology to use for data operations?

1) Linq to Entities 2) Linq to SQL 3) Fluent NHibernate 4) ADO.Net

Website will be based on ASP.Net MVC and C#.

Main Issues:

1) Should be easy to maintain and scale.

2) Good Performance

Please express your view with an example if possible..

Thanks

Chitresh

回答1:

Pro and cons:

LINQ To Entities

Allows you to add another layer of abstraction (entity) instead of mapping directly to tables (like in LINQ to SQL). Support multiple data providers (not just SQL Server). Require a bit more learning time than LINQ to SQL. Provide unit of work concept. Medium to High learning curve.

LINQ to SQL

Allows you to easily map your tables, stored procs, etc. Provide unit of work concept. Only work on SQL Server backend. Easy to implement, but require dbml rebuild if db schema changes (1 way synchronization from db to object), so a bit harder to maintain. Low - Medium learning curve. Performance, ... I think Stack Overflow is using LINQ to SQL. How do you think it performs? Have unit of work concept.

Fluent NHibernate

Can't comment ... know nothing about it. If it is anything like NHibernate, should be quite flexible. Probably high learning curve. Someone correct me on this...

ADO.NET (Not talking about Named DataSet here...)

Should be the fastest (no abstraction). Flexible, bend it anyway you want. Low learning curve. Very basic, do everything yourself approach. Most of the time I go this route for simple project. Can lower productivity. You can augment it with code generation to gain some productivity.

Your other options... Subsonic perhaps.



回答2:

NHibernate(Fluent NHibernate)

Fluent NHibernate is a component to help you map your Entities so that NHibernate knows where it's gonna put your data from the database. If you never used NHibernate it can be a little difficult to know how to map and handle a NHibernateSession but there are lots of information here on stackoverflow and other places like S#arp for an exemple of session handling and Summer of NHibernate to get some lessons in mapping.



回答3:

I would go with Linq to Entities or NHibernate (actually, I would go with NHibernate, but that is one I'm the most familiar with) -- AND ADO.Net (but just a little bit).

Start by doing everything you can with NHibernate/Entities. Once it is up and going you will find it remarkably productive. But there are situations where you will need a bit more performance (do you have a good profiling tool?). For those cases, code them in straight Ado.Net (that should make up less than 10% of your database calls). With NHibernate, you can use the NHibernate session to get your connection object for you as well.