I usually use the term entity
to represent a business data object and in my mind, the linq to entities
and linq to objects
were the same. Is that not correct?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Linq to entities is intended to be used with Entity Framework while Linq to objects is for any IEnumerable collection.
More details:
That is definitely not the case.
LINQ-to-Objects is a set of extension methods on
IEnumerable<T>
that allow you to perform in-memory query operations on arbitrary sequences of objects. The methods accept simple delegates when necessary.LINQ-to-Entities is a LINQ provider that has a set of extension methods on
IQueryable<T>
. The methods build up an expression tree (which is why delegates are actually passed asExpression<>
s), and the provider will build up a SQL query based on its parsing of that expression tree.As an example, consider the following queries:
The first query is will build up an expression tree consisting of a select and a where, with the two lambdas actually considered as
LambdaExpression
s. The LINQ-to-Entities provider will translate that into SQL that both selects and filters.The second query inserts an
AsEnumerable()
, which will force the remainder of the query to use LINQ-to-Objects. In that case, the provider will generate SQL based on only the selection, return all those records from the database, and then the filtering will occur in-memory. Obviously, that's likely going to be much slower.Linq to Objects The term "LINQ to Objects" refers to the use of LINQ queries with any IEnumerable or IEnumerable collection directly, without the use of an intermediate LINQ provider or API such as LINQ to SQL or LINQ to XML. You can use LINQ to query any enumerable collections such as List, Array, or Dictionary. The collection may be user-defined or may be returned by a .NET Framework API.
In a basic sense, LINQ to Objects represents a new approach to collections. In the old way, you had to write complex foreach loops that specified how to retrieve data from a collection. In the LINQ approach, you write declarative code that describes what you want to retrieve.
ref :http://msdn.microsoft.com/en-us/library/bb397919.aspx
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: Ref : http://msdn.microsoft.com/en-us/library/bb386964.aspx
Linq2Entities stands for querying data via the ADO.NET Entity Framework (Database)
Linq2Objects stands for querying in memory data (local objects).
L2o is for in-memory objectes. L2e queries a database.