Each consumes an IQueryable, which is simply a pairing of an expression tree ( Expression) with a query provider ( IQueryProvider). The methods in operate in a different manner. Since the underlying sequence generally exists in memory, or is easily acquired, there is no real concern about the mechanism by which it is fetched. Most of the methods in simply create a new instance of IEnumerable that wraps the one on which it operates. LINQ Part 4: A Deep Dive Into a Queryable Extension Method.LINQ Part 3: An Introduction to IQueryable.LINQ Part 2: Standard Methods - Tools in the Toolbox.LINQ Part 1: A Deep Dive into IEnumerable.Links to other articles in this series are as follows: This is the third in a series of articles on LINQ. While conceptually similar, these methods accomplish their goal in an entirely different manner: they build the expression tree. While this reduces the learning curve for developers, it is also deceptive. They all share identical names and near identical syntax with their counterparts in. It simply pairs a query provider with an expression tree.Īs with IEnumerable, LINQ provides a set of standard methods, defined in the class. Queryable sequence ( IQueryable) - This is the approximate equivalent to IEnumerable in LINQ to Objects.This should be familiar to anyone who has ever written a parser or compiler. This tree is later analyzed by the query provider. Expression tree ( Expression) - A tree is formed from elements of a query.Query provider ( IQueryProvider) - This is specialized software that can interpret a query, so that it efficiently utilizes the underlying resources.To facilitate this, LINQ introduces the following new concepts: Finally, we want to take advantage of all of the "smarts" of the database product. Also, we want to request as little information as possible. With other data sources, this would be inefficient.įor example, for a database, we want to make as few round-trips to the server as possible. With LINQ to Objects, LINQ can simply provide standard methods that operate directly on the sequences that are queried. This article will explore these concepts. To support this very different requirement, LINQ introduces the concepts of query provider ( ), expression tree ( ), and queryable sequence ( ). In fact, it may even exist on an entirely different machine. databases) where the information does not reside in local memory. Together these form a small, but crucial part of LINQ, known as LINQ to Objects.Īnother important aspect of LINQ is its ability to query other data sources (e.g. In this series, we've explored IEnumerable and taken a look at the standard methods that extend this interface.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |