如何是.NET实体框架矫枉过正与LinqToSql? [英] How is the .net Entity Framework overkill versus LinqToSql?

查看:186
本文介绍了如何是.NET实体框架矫枉过正与LinqToSql?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听到有人说,实体框架是矫枉过正或者说,它是很难学习相比,LinqToSql。

I've heard it said that the Entity Framework is overkill or that it's difficult to learn compared to LinqToSql.

我想知道用什么方式?我用LinqToSql和喜欢它。所以,我想的EF和为事我做他们似乎同出一辙。命名空间和方法的名称不同,但到目前为止,我没有看到任何东西,使EF难度比LinqToSql。

I am wondering in what way? I used LinqToSql and like it. So, I am trying the EF and for the things I'm doing they seem almost exactly the same. Namespaces and method names are different but so far I don't see anything that makes the EF harder than LinqToSql.

我敢肯定,如果我开始做多情结的事情就变得更加复杂。但是,有一次,我可能不能做LinqToSql同样的事情都让我看到,作为EF以防万一加我做想做的事更复杂的东西。

I'm sure if I start doing more comples things it gets more complex. But then again I probably can't do the same thing with LinqToSql at all so I see that as a plus for the EF just in case I do want to do something more complex.

请问EF使用更多的资源比LinqToSql以至于我不应该使用它,如果我需要的是LinqToSql一样的功能?

Does the EF use more resources than LinqToSql so much so that I should not use it if all I need is LinqToSql-like functionality?

更新: 我做了一些测试,我的测试似乎指向LINQ到比LINQ的表现更好,以SQL实体。

Update: I did some tests and my tests seems to point to Linq to Entities performing better than Linq to SQL.

我第一次从一个单一的表中删除1000条记录,添加1000条记录,编辑1000条记录,然后这些数据绑定到DataView。 LinqToSQL:5秒LinqToEntities:2秒

I first delete 1000 records from a single table, add 1000 records, edit 1000 records and then databind them to a DataView. LinqToSQL: 5 seconds LinqToEntities: 2 seconds

予执行使用两个联接的表相同的测试,结果相似。

I performed the same test using two joined tables and the results were similar.

我的测试似乎支持另一篇文章: <一href="http://stackoverflow.com/questions/257016/linq-to-sql-vs-entity-framework-performance">http://stackoverflow.com/questions/257016/linq-to-sql-vs-entity-framework-performance

My tests seem to support another post: http://stackoverflow.com/questions/257016/linq-to-sql-vs-entity-framework-performance

更新2:

感谢您的答复。看来,我认为LINQ到实体是不是真的矫枉过正与LINQ到SQL。研究越觉得使用LINQ去实体后是要走的路。它似乎有更好的表现。

Thanks for the replies. It appears to me that Linq to Entities isn't really overkill versus Linq to SQL. After researching more I think going with Linq to Entities is the way to go. It appears to have better performance.

我相信,我已经听到了矫枉过正声明是因为LINQ到实体可以做的比LINQ的多为SQL和它确实需要更多的配置(约1线在web.config)。还有一些小东西的LINQ到实体确实不同于LINQ到SQL可能让别人觉得好像LINQ到实体更为复杂。但是,一旦你学会了如何做的事情似乎LINQ到实体并不比LINQ的更复杂的SQL。

I believe the "overkill" statements that I've heard are made because Linq to Entities can do much more than Linq To SQL and it does require more configuration (about 1 more line in the web.config). Also there are small things that Linq to Entities does differently from Linq to SQL that might make someone feel as though Linq to Entities is more complicated. But once you learn how to do things it seems Linq to Entities is no more complicated than Linq to SQL.

推荐答案

我的回答:执行执行一个简单的GET /编辑/更新程序所花费的时间简单comparsion。我想你会发现LINQ to SQL的两倍快。我做了一个快速comparsion项目时,我正在调查的差异。
结果,其中: 实体框架8700毫秒 LINQ到SQL 3100毫秒 数据集200​​0毫秒

My answer: Do a simple comparsion of the time taken to perform a simple Get/Edit/Update sequence. I think you will find that LINQ to SQL is twice as quick. I did a quick comparsion project when i was investigating the differences.
The results where: Entity Framework 8,700 milliseconds LINQ to SQL 3,100 milliseconds Data-sets 2,000 milliseconds

所以对我来说这是一个简单的问题。使用DataSet或使用Linq-SQL - 实体框架甚至没有的因素进去

So for me it was a simple question. Use DataSets or use Linq-Sql - Entity Framework didn't even factor into it!

链接文本

这篇关于如何是.NET实体框架矫枉过正与LinqToSql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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