ADO.NET实体框架和Linq to Entities

时间:2021-04-12 02:09:01

I'm confused about Linq to Entities. Is it the new name of Entity Framework or are they different things?

我对Linq to Entities感到困惑。它是实体框架的新名称还是不同的东西?

1 个解决方案

#1


LINQ to Entities is really simply the standard LINQ extension methods (Where, OrderBy, etc), when used to query Entity Framework. This isn't the only option; EF can also be queried in a custom dialect of SQL - Entity SQL. In reality, the LINQ extension methods are used to generate Entity SQL, and then that Entity SQL is passed down to the provider.

LINQ to Entities实际上只是标准的LINQ扩展方法(Where,OrderBy等),当用于查询Entity Framework时。这不是唯一的选择; EF也可以用SQL的自定义方言查询 - 实体SQL。实际上,LINQ扩展方法用于生成实体SQL,然后将实体SQL传递给提供者。

That way, people implementing a new EF provider (since it is extensible) only have to worry about one thing for query: Entity SQL.

这样,实现新EF提供程序的人(因为它是可扩展的)只需要担心查询的一件事:实体SQL。

Of course, to strictly count as LINQ, you would need to use the language part too, i.e.

当然,要严格计算为LINQ,您还需要使用语言部分,即

from product in db.Products
     where product.IsActive
     select product.Name;

etc - but since this boils down to extension methods anyway (on Queryable/IQueryable<T>), most people would count direct extension usage as LINQ - i.e.

等等 - 但是因为无论如何这归结为扩展方法(在Queryable / IQueryable 上),大多数人会将直接扩展使用计为LINQ - 即

var qry = db.Products.Where(x=>x.IsActive).Select(x=>x.Name);

#1


LINQ to Entities is really simply the standard LINQ extension methods (Where, OrderBy, etc), when used to query Entity Framework. This isn't the only option; EF can also be queried in a custom dialect of SQL - Entity SQL. In reality, the LINQ extension methods are used to generate Entity SQL, and then that Entity SQL is passed down to the provider.

LINQ to Entities实际上只是标准的LINQ扩展方法(Where,OrderBy等),当用于查询Entity Framework时。这不是唯一的选择; EF也可以用SQL的自定义方言查询 - 实体SQL。实际上,LINQ扩展方法用于生成实体SQL,然后将实体SQL传递给提供者。

That way, people implementing a new EF provider (since it is extensible) only have to worry about one thing for query: Entity SQL.

这样,实现新EF提供程序的人(因为它是可扩展的)只需要担心查询的一件事:实体SQL。

Of course, to strictly count as LINQ, you would need to use the language part too, i.e.

当然,要严格计算为LINQ,您还需要使用语言部分,即

from product in db.Products
     where product.IsActive
     select product.Name;

etc - but since this boils down to extension methods anyway (on Queryable/IQueryable<T>), most people would count direct extension usage as LINQ - i.e.

等等 - 但是因为无论如何这归结为扩展方法(在Queryable / IQueryable 上),大多数人会将直接扩展使用计为LINQ - 即

var qry = db.Products.Where(x=>x.IsActive).Select(x=>x.Name);

相关文章