.net Framework 4.0 中的 Linq2SQL 与 EF [英] Linq2SQL vs EF in .net Framework 4.0

查看:30
本文介绍了.net Framework 4.0 中的 Linq2SQL 与 EF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那么现在对这两款产品的评价如何?对于 VS2010/.net 4.0,我似乎找不到关于这个问题的任何信息

So what's the verdict on these two products now? I can't seem to find anything regarding this issue SPECIFICALLY for VS2010/.net 4.0

回到 .net 3.5 天,大多数人认为 Linq2SQL 会在 .net 4.0 出现时消亡,但它似乎还活着.

Back in .net 3.5 days, most people believe Linq2SQL will be dead when .net 4.0 comes around, but it seems alive and well.

另一方面,EF 4.0 似乎有了显着的改进.

On the other hand, EF 4.0 seems to have gotten significant improvement.

对我来说,到目前为止,我的大部分工作都是中小型项目,我的公司很快就会从 VS08 迁移到 VS10.我应该看什么?或者说真的,我应该花时间学习 EF4.0 还是花时间研究 nHibernate?(但回到主题,我真的对 Linq2Sql - EF 更感兴趣.)

For me, most of my work so far are small to medium sized projects, and my company is migrating from VS08 to VS10 soonish. What should I be looking at? Or really, should I spend the time studying EF4.0 or would it be time more well spent looking at nHibernate? (But back on topic, I'm really more interested in Linq2Sql - EF.)

最后,我目前在用entlib/unity,哪个框架对依赖/策略注入更友好?

Lastly, I am currently using entlib / unity, which framework is more friendly for dependency/policy injection?

提前致谢.

推荐答案

以下是 Entity Framework (v4) 更好的一些原因:

Here are some reasons why Entity Framework (v4) is better:

1 - L2SQL 基本上过时

1 - L2SQL is essentially obsolete

2 - L2SQL 不支持 POCO 映射,EF 支持.

2 - L2SQL does not support POCO mapping, EF does.

3 - EF 具有更大的灵活性(代码优先、模型优先、数据库优先).L2SQL只有1个.

3 - EF has more flexibility (code first, model first, database first). L2SQL has only 1.

4 - EF 支持 SPROC -> POCO 映射

4 - EF has support for SPROC -> POCO mapping

5 - EF 具有 Entity-SQL,允许您在需要时返回到经典的 ADO.NET

5 - EF has Entity-SQL, allowing you to go back to classic ADO.NET when required

6 - EF 支持继承(TPT、TPH)

6 - EF supports inheritance (TPT, TPH)

7 - EF 与 Repository 模式携手并进,并通过 IQueryable 延迟执行

7 - EF goes hand-in-hand with Repository pattern, and deferred execution via IQueryable

8 - EF 组件(ObjectSet、ObjectContext)很容易模拟并允许 DI

8 - EF components (ObjectSet, ObjectContext) are easily mockable and allow for DI

我想不出新项目应该使用 L2SQL 的任何理由.

I cannot think of any reason why new projects should use L2SQL.

有些人可能会说好吧,L2SQL 适用于小型项目,我可以拖放并完成它".

Some might say "Well L2SQL is good for small projects, i can drag and drop and be done with it".

好吧,您也可以使用 EF4 做到这一点,如果您决定修改/发展您的项目,从长远来看,您将获得更多的灵活性/支持.所以这不是借口.

Well you can do that with EF4 as well, and you'll have more flexibility/support in the long run if you decide to modify/grow your project. So that is not an excuse.

HTH

这篇关于.net Framework 4.0 中的 Linq2SQL 与 EF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆