I have tried some ways to use LINQ dynamic queries - LINQKit and LINQ Dynamic Query Library. I do not like the second because it some way kills the LINQ idea - to be able to check queries at compile time. And with LINQKit I did not find a good example for my scenario. Also I do not like excessive using of reflection.
My scenario is the following. I have a web service which is doing business logic and DAL logic. The webforms application is separated. I have some page with tickboxes for each field the user would like to filter, and also a text box to enter each filter value. My web service has a method GetByFilter where I pass some List. QueryObject is a class with string: filedName, object: fieldValue.
Then my webservice receives list of query objects and now comes the big question: how to translate it to LINQ query if the field count and filter values may vary?
What's even worse - I do not use LINQ2SQL but I use some custom DAL with repositories which may return IQuery if needed (like this one: http://msdn.microsoft.com/en-us/magazine/dd569757.aspx scroll to Repository).
I know I can use paging with LINQ2SQL: var PagedData = query.Skip((iPageNum - 1) * iPageSize).Take(iPageSize);
So how then I can get the dynamic query parameters (and iPageNum and iPageSize) from LINQ to my underlying DAL implementation to execute those queries in a dataprovider specific way? Maybe I have to implement my DAL as some LINQ data provider (I have no idea how to do it)?
The problem is - I do not want to depend on LINQ2SQL (then I could just implement my Repositories as a wrappers for LINQ2SQL) but at the same time I want to have LINQ querying abilities everywhere outside my DAL. Is it possible?