|TABLE OF CONTENTS|
| LINQ Quick Start
LINQ and Visual Studio 2008's new language features
LINQ and Web applications
LINQ to Objects
LINQ to XML
LINQ to SQL
LINQ to DataSet
LINQ to Entities
Third-party LINQ Implementations
VISIT OUR OTHER LEARNING GUIDES
Matt Warren, author of The Wayward Weblog and an architect on Microsoft's C# programming team, has put together a nice seven-part series on how to use IQueryable and IQueryProvider to build a LINQ provider, which is a way to make a data source accessible through LINQ.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Part I: Reusable IQueryable base classes
Here Warren offers an introduction to IQueryable, IQueryProvider, the CreateQuery method and the Execute method. "The real action happens inside the Execute method," he indicates. "That's where your provider has the opportunity to make sense of the query by examining the expression tree."
Part II: Where and reusable Expression tree visitor
In this installment Warren starts working on the sample provider. It's designed to translate a query into SQL command text and then translate the result of executing that command into objects. There's also an appendix that explains how to build an Expression Visitor.
Part III: Local variable references
Since the sample provider only understands one major query operator (and a few minor ones), and since the C# compiler makes a separate class for holding local variables, the LINQ provider needs to make sense of the trees that the compiler generates. Here Warren takes the Expression Visitor and uses it to write a rule for evaluating those trees.
Part IV: Select
The next step is to implement the Select method. In the LINQ Select operator, this can be done in many, many ways. "Fortunately, it's still easy. I just have to convert the selector function I already have into the one I need," Warren indicates. It involves getting the QueryTranslator to handle the Select method and return a lambda expression that is subsequently read by an ObjectReader.
Part V: Improved Column binding
This posts aims to fix the "gaping holes" in the LINQ expression trees, the QueryTranslator and the ColumnProjector that have been glossed over in Warren's head-first dive into his code.
Part VI: Nested queries
At this point Warren needs to finish off the Select method. He does so by executing a nested query. Watch what happens.
Part VII: Join and SelectMany
In this final post, Warren adds Join and SelectMany methods to his LINQ provider, seeing as, until now, it had only been executing Select and Where methods.
*** Go on to the next section of the LINQ Learning Guide: LINQ and Web applications