This is a migrated thread and some comments may be shown as answers.
1 Answer 13 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Top achievements
Rank 2
Steve asked on 11 Jun 2010, 05:31 PM
What's the best way to do optional filtering?

So for example if this is my main query
List<ViewAllRequest> requests = (from r in scope.Extent<ViewAllRequest>() 
                                 select r).ToList(); 

But the user has specified they want 3 (of 10 possible) filters Name, or Email...

How do I then filter that result set down, or BETTER, filter with the initial query?

1 Answer, 1 is accepted

Sort by
Damyan Bogoev
Telerik team
answered on 16 Jun 2010, 04:50 PM
Hi Steve,

I recommend you using our code library example “Using Telerik OpenAccess ORM with Dynamic LINQ”. It demonstrates how to create dynamically Linq queries.
Other approach you could use is the IQueryable interface. It provides functionality to evaluate queries against a specific data source:

IQueryable<Product> query = context.Products;
if (!string.IsNullOrEmpty(searchString))
   query = query.Where(c => c.ProductName.Contains(searchString));

I hope this solution provides helpful for you.

All the best,
Damyan Bogoev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
LINQ (LINQ specific questions)
Asked by
Top achievements
Rank 2
Answers by
Damyan Bogoev
Telerik team
Share this question