.net实体框架如何与LinqToSql相比过高? [英] How is the .net Entity Framework overkill versus LinqToSql?

查看:126
本文介绍了.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.

我确定如果我开始做更多的comples的事情变得越来越复杂。但是再一次,我可能根本不能和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 to Entities表现优于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.

我的测试似乎支持另一个帖子:
Linq To Sql vs实体框架性能

My tests seem to support another post: Linq To Sql vs Entity Framework Performance

更新2:

感谢您的回复。在我看来,Linq to Entities并不是真的太过分了,而是Linq to SQL。在研究更多之后,我认为与林克到实体是走的路。似乎有更好的表现。

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.

我相信我听说过的overkill语句是因为Linq to Entities可以比Linq To SQL做得更多,它需要更多的配置(约1更多的行在web.config)。还有一些小东西,Linq to Entities做的不同于Linq到SQL,这可能会让某人觉得Linq对实体的复杂度更高。但是一旦学习了如何做事情,似乎Linq to Entities并不比Linq to 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 / Edit / Update序列。我想你会发现LINQ to SQL的速度是两倍。我在调查差异时做了一个快速的比较项目。

结果其中:
实体框架8,700毫秒
LINQ到SQL 3,100毫秒
数据集2000毫秒

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

所以对我来说这是一个简单的问题。使用数据集或使用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天全站免登陆