views:

46

answers:

2

I have a page which gives user to generate report based on different filters selected. I need some suggestion or idea on my thoughts

  1. Loop through each filter control (checkbox, multi select list, radiobox list) and build dynamic where conditions and conjunctions for each filter and then run query

  2. Get all the data (i think this will causes an overload with all 4-5 tables joined) and then use Linq to filter this data based on user selection

  3. Is there a better way to implement this?

A: 

I've created an advanced search page in the past using what sounds similar to your first thought. My solution was similar to this SO question, "Advice for Building a dynamic “Advanced Search” Control in ASP.NET". It's not so much the answers to this question that I think are relevant to your question, but where he describes his implementation of what I believe is similar to what you are asking.

A serviceable set of API objects representing entities, fields, and searches, which handles constructing a search, generating SQL, and returning the results.

David Glass
I have filters like Department then employees, then their sub section and in each subsection other values. And their can be multiple department and multiple employees selected in each.
rs
A: 

I use this linq predicate builder:

http://www.albahari.com/nutshell/predicatebuilder.aspx

FiveTools