Thread is closed for posting
2 posts, 0 answers
  1. Steve
    Steve avatar
    1887 posts
    Member since:
    Dec 2008

    Posted 11 Jun 2010 Link to this post

    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?
  2. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 16 Jun 2010 Link to this post

    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.
Back to Top