linq to object 与 linq to entity

一、linq to object

The term "LINQ to Objects" refers to the use of LINQ queries with any IEnumerable or IEnumerable<T> collection directly,

without the use of an intermediate LINQ provider or API such as LINQ to SQL [LINQ to SQL] or LINQ to XML.

You can use LINQ to query any enumerable collections such as List<T>Array, or Dictionary<TKey, TValue>.

The collection may be user-defined or may be returned by a .NET Framework API.

 

通过以上定义,linq to object 即对List<T>Array, or Dictionary<TKey, TValue>对象的查询。

二、linq to entity

LINQ to Entities provides Language-Integrated Query (LINQ) support that enables developers to write queries against the Entity Framework conceptual model using Visual Basic or Visual C#. Queries against the Entity Framework are represented by command tree queries, which execute against the object context. LINQ to Entities converts Language-Integrated Queries (LINQ) queries to command tree queries, executes the queries against the Entity Framework, and returns objects that can be used by both the Entity Framework and LINQ. The following is the process for creating and executing a LINQ to Entities query:

  1. Construct an ObjectQuery<T> instance from ObjectContext.

  2. Compose a LINQ to Entities query in C# or Visual Basic by using the ObjectQuery<T> instance.

  3. Convert LINQ standard query operators and expressions to command trees.

  4. Execute the query, in command tree representation, against the data source. Any exceptions thrown on the data source during execution are passed directly up to the client.

  5. Return query results back to the client.

通过以上定义,对通过DBcontext对象创建出来的实例,才归属entity,对该对象的查询才是linq to entiry.

 

posted @ 2021-01-26 14:36  windy3417  阅读(89)  评论(0编辑  收藏  举报