LINQ combines two architectural models: in-memory local and remote.
The first one is basically LINQ-to-Objects and LINQ-to-XML. Local model closely work withIEnumerable<T> and decorator sequences of C# methods, lambdas and delegates. The query is compiled into standard imperative IL code.
The second one is LINQ-to-SQL and LINQ-to-Entities. Remote model in contrast is rather declarative to the runtime. Sequences in query implement the IQueryable<T> (which in turn derives fromIEnumerable<T>) and after the compilation resolve into query operators from Queryable class – expression trees. Depending on the query provider, expression trees will be later interpreted by the runtime and are “friendly” to the remote data source.
So far, we’ve examined the architecture of local queries,which operate over collections implementing IEnumerable<>. Local queries resolve to query operators in the Enumerable class, which in turn resolve to chains of deco-rator sequences. The delegates that they accept—whether expressed in comprehension syntax, lambdasyntax, or tradi-tional delegates—are fully local to Intermediate Language(IL) code just as any other C# method.
Bycontrast, interpreted queries are descriptive. They operate over sequences that implement IQueryable<>, and they resolve to the query operators in the Queryable class, which emit expression trees that are interpreted at runtime.
There are two IQueryable implementations in the .NET Framework:
•LINQ to SQL
•LINQ to Entities
In addition, the AsQueryable extension method generates an IQueryable wrapper around an ordinary enumerable collection.
So far, we’ve examined the architecture of local queries,which operate over collections implementing IEnumerable<>. Local queries resolve to query operators in the Enumerable class, which in turn resolve to chains of deco-rator sequences. The delegates that they accept—whether expressed in comprehension syntax, lambdasyntax, or tradi-tional delegates—are fully local to Intermediate Language(IL) code just as any other C# method.
Bycontrast, interpreted queries are descriptive. They operate over sequences that implement IQueryable<>, and they resolve to the query operators in the Queryable class, which emit expression trees that are interpreted at runtime.
There are two IQueryable implementations in the .NET Framework:
•LINQ to SQL
•LINQ to Entities
In addition, the AsQueryable extension method generates an IQueryable wrapper around an ordinary enumerable collection.
No comments:
Post a Comment