Wednesday, April 25, 2012

Building a dynamic search with LINQ (think WHERE chaining)

Paul Sheriff's Blog for the Real World - Dynamic Search with LINQ, the Entity Framework and Silverlight – Part 2

"After my previous blog post, I realized that using SQL strings is not a great way to do things. Sometimes we start blogging too quick and then realize our mistakes after. But, no big deal, live and learn... I am going to now rewrite this application and use some lambda expressions to solve the problems inherit with concatenating strings to SQL statements; namely escaping a single quote and SQL Injection attacks. I am going to use the same search screen shown in Figure 1.


I thought this an interesting example of building a dynamic, user driven, multiple field query (or "where" wizard). Not sure I like the case usage (that looks like it could easily spiral out of maintenance control), but it does make it easy to read and grok (and this is just a demo)...

1 comment:

Mike Ward said...

Predicate Builder is a much better option IMHO.