何时使用“LINQ to SQL”,实体框架或NHibernate?

时间:2021-08-08 16:48:43

With .NET, which data access method is better to use "LINQ to SQL",entity framework, or NHibernate?

使用.NET,哪种数据访问方法更好地使用“LINQ to SQL”,实体框架或NHibernate?

Should a different method be used depending on the situation or is it more of a personal preference?

是否应该根据具体情况采用不同的方法,还是更多的个人偏好?

If so which method and when?

如果是这样的方法和时间?

3 个解决方案

#1


MVC is unrelated to data access. If you're wondering whether to choose between Linq2Sql, EF or something else, my answer until the release of the new EF is to go with NHibernate, fluent or otherwise.

MVC与数据访问无关。如果你想知道是否要选择Linq2Sql,EF或其他什么,我的答案直到新EF的发布是与NHibernate,流利或其他。

#2


I depends on the complexity and goals of the project . If you are aiming at bringing some simple sets of data in using plain sql then linq-to-sql is good . But if you are planning to take advantage of sophistication of full fledged ORM , like first and second level caching, transactional write behind, oo query language,plugin points ect.. then Nhibernate is the way to go .

我取决于项目的复杂性和目标。如果你的目标是使用普通的sql带来一些简单的数据集,那么linq-to-sql是好的。但是如果你打算利用完全成熟的ORM的复杂性,比如一级和二级缓存,事务性写入,oo查询语言,插件点等等,那么Nhibernate就是要走的路。

#3


MVC has nothing to do with data.

MVC与数据无关。

I also wonder where you've been hiding if you've been hearing about these things "every couple of months". Both LINQ to SQL and Entity Framework were part of .NET 3.5, released last year.

如果你“每隔几个月”听说过这些事情,我也想知道你一直在躲藏在哪里。 LINQ to SQL和Entity Framework都是去年发布的.NET 3.5的一部分。

#1


MVC is unrelated to data access. If you're wondering whether to choose between Linq2Sql, EF or something else, my answer until the release of the new EF is to go with NHibernate, fluent or otherwise.

MVC与数据访问无关。如果你想知道是否要选择Linq2Sql,EF或其他什么,我的答案直到新EF的发布是与NHibernate,流利或其他。

#2


I depends on the complexity and goals of the project . If you are aiming at bringing some simple sets of data in using plain sql then linq-to-sql is good . But if you are planning to take advantage of sophistication of full fledged ORM , like first and second level caching, transactional write behind, oo query language,plugin points ect.. then Nhibernate is the way to go .

我取决于项目的复杂性和目标。如果你的目标是使用普通的sql带来一些简单的数据集,那么linq-to-sql是好的。但是如果你打算利用完全成熟的ORM的复杂性,比如一级和二级缓存,事务性写入,oo查询语言,插件点等等,那么Nhibernate就是要走的路。

#3


MVC has nothing to do with data.

MVC与数据无关。

I also wonder where you've been hiding if you've been hearing about these things "every couple of months". Both LINQ to SQL and Entity Framework were part of .NET 3.5, released last year.

如果你“每隔几个月”听说过这些事情,我也想知道你一直在躲藏在哪里。 LINQ to SQL和Entity Framework都是去年发布的.NET 3.5的一部分。