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:
-
Construct an ObjectQuery<T> instance from ObjectContext.
-
Compose a LINQ to Entities query in C# or Visual Basic by using the ObjectQuery<T> instance.
-
Convert LINQ standard query operators and expressions to command trees.
-
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.
-
Return query results back to the client.
通过以上定义,对通过DBcontext对象创建出来的实例,才归属entity,对该对象的查询才是linq to entiry.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步