Creating a Dynamic, Runtime, User Driven Query Builder with LINQ
The Visual Basic Team - Implementing Dynamic Searching Using LINQ
"A common requirement in forms-over-data applications is that users be able to search by any combination of fields to construct a dynamic query at run time. For example, the search feature in this application allows the user to find all records that meet criteria defined on multiple columns:
This is easy at compile-time, but what if we want to check the date the order was entered instead of the date it was shipped? In this case we’d have to write a separate query using order.OrderDate. Doing this dynamically at runtime isn’t all that difficult if you’re just building up a SQL string, but how would we do this with LINQ? Doesn’t LINQ require me to specify the criteria at compile time in order to construct the query? Fortunately the answer’s no, LINQ supports constructing dynamic queries at runtime through the Expression Tree API and the Expression Compiler.
..."
This is a wheel that we seem to reinvent all the time, isn't it? A user driver query builder...
This post provides an interesting solution and uses many of the new cool VB9 features like expression trees, lambda expressions, LINQ, etc.
I'm going to queue this for a closer look when VS2008 RTM's.
No comments:
Post a Comment