简体   繁体   English

LINQ和实体框架之间有什么不同?

[英]What's Different Between LINQ and Entity Framework?

I know the benefit of the LINQ and I know use of it in .Net Application. 我知道LINQ的好处,我知道在.Net应用程序中使用它。 I fill same thing there are providing as a Entity Framework. 我填写了作为实体框架提供的相同内容。

So What's Major Difference between LINQ and Entity Framework? 那么LINQ和实体框架之间的主要区别是什么?

LINQ could be applied to any data source: in-memory objects, XML, SQL, ... LINQ可以应用于任何数据源:内存中对象,XML,SQL,......

Entity Framework could use LINQ to perform queries against a relational database. 实体框架可以使用LINQ对关系数据库执行查询。

LINQ to SQL is the predecessor of Entity Framework and is obsolete now. LINQ to SQL是Entity Framework的前身,现在已经过时了。

Comparing EF and LINQ is incorrect. 比较EF和LINQ是不正确的。 Both are different things and they often work together to give better developer experience (and productivity benefit). 两者都是不同的东西,它们经常一起工作,以提供更好的开发人员体验(和生产力效益)。

LINQ is querying syntax/model that can be applied to any data source. LINQ查询可应用于任何数据源的语法/模型。 EF provides one such data source. EF提供了一个这样的数据源。

They are somewhat similar, and can be used in a very similar way, code-wise, but they have some important differences. 它们有点相似,并且可以以非常类似的方式使用,代码方面,但它们有一些重要的区别。 Note that "LINQ" is not the same thing as "LINQ to SQL"; 请注意,“LINQ”与“LINQ to SQL”不同; the EF also uses LINQ. EF也使用LINQ。 Some notable differences are: 一些值得注意的差异是:

  • LINQ to SQL is largely SQL Server only, not so much by design as by implementation. LINQ to SQL主要是SQL Server,而不是设计和实现。 The EF is designed to support, and does support, multiple DBs, if you have a compatible ADO.NET provider. 如果您有兼容的ADO.NET提供程序,则EF旨在支持并支持多个DB。
  • Out of the box, LINQ to SQL has a very poor story for DB metadata changes. 开箱即用,LINQ to SQL的数据库元数据更改故事非常糟糕。 You have to regenerate parts of your model from scratch, and you lose customizations. 您必须从头开始重新生成模型的某些部分,否则会丢失自定义。
  • The EF supports model features like many-to-many relationships and inheritance. EF支持多对多关系和继承等模型功能。 LINQ to SQL does not directly support these. LINQ to SQL不直接支持这些。
  • In .NET 3.5, LINQ to SQL had much better support for SQL-Server-specific functionality than the EF. 在.NET 3.5中,LINQ to SQL比EF更好地支持特定于SQL Server的功能。 This is mostly not true in .NET 4; 这在.NET 4中大多不适用; they're fairly similar in that respect. 他们在这方面非常相似。
  • The EF lets you choose Model First, DB First, or Code First modeling. EF允许您选择Model First,DB First或Code First建模。 LINQ to SQL, out of the box, really only supports DB First. LINQ to SQL,开箱即用,实际上只支持DB First。

SOURCE : Here 消息来源: 这里

I totally agree with VinayC. 我完全同意VinayC。 You cannot really compare. 你不能真正比较。

With Entity Framework, you will be able to have a whole representation of your database in your program. 使用Entity Framework,您将能够在程序中拥有数据库的完整表示。 It will help you create classes corresponding to the database elements, connected together like they are in the database. 它将帮助您创建与数据库元素相对应的类,它们像在数据库中一样连接在一起。 You can after interact with elements of theses classes directly, and like this impact the database. 您可以直接与这些类的元素进行交互,并且这样会影响数据库。 You will have some representation of these classes diagram in visual studio. 您将在visual studio中对这些类图表进行一些表示。 It's basically often simpler than working directly with the database elements, even if setting it up requires some effort. 它基本上比直接使用数据库元素更简单,即使设置它需要一些努力。

The use of Linq is to perform queries on the data sources. Linq的使用是对数据源执行查询。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 实体框架和linq之间的混淆 - confusion between entity framework and linq 实体框架中LINQ-to-SQL的ExecuteCommand相当于什么? - What is the equivalent of LINQ-to-SQL's ExecuteCommand in Entity Framework? 实体框架:LINQ查询在本地执行和服务器执行之间生成不同的SQL - Entity Framework: LINQ query generates different SQL between local execution and server execution Linq-to-SQL中的SubmitChanges和Entity Framework中的SaveChanges之间的技术差异是什么? - What is technical difference between SubmitChanges in Linq-to-SQL and SaveChanges in Entity Framework? 实体框架的版本之间生成的查询不同 - Generated Query is different between versions of Entity Framework nhibernate和实体框架在批处理之间有什么区别? - What is the difference between nhibernate and entity framework in batching? 这两个语句之间有什么区别(实体框架) - What is the difference between these two statements (Entity Framework) 带有单个和多个SaveChanges()调用的Entity Framework(6)事务之间有什么区别 - What's the difference between Entity Framework (6) transactions with single and multiple SaveChanges() calls 实体框架:LINQ to Entities分配产生不同的ObjectContext对象错误 - Entity Framework: Different ObjectContext object error with LINQ to Entities assignment 使用Entity Framework和Linq对不同的表进行相同的选择 - Make the same select to different tables using Entity Framework and Linq
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM