build free text search linq query

2 posts, 0 answers
  1. Tys
    Tys avatar
    14 posts
    Member since:
    Jul 2011

    Posted 14 Apr 2012 Link to this post

    I have a textbox that takes free text as input for a search and I have a LINQ query that I want to extend with this type of search.

    The input could be something like "big blue car" and that should result in a query that searches for titles that contain all these words.

    There is also an option to switch to "any word" instead of "all words".

    What is the best/easiest way to add this to my LINQ query?

    The query now looks like

    from b in books
    where b
    .InStore == true && b.Price > 10 && title.Contains() this point i want to add the text search.
    select b

    And i think i have to do something like this:

    var searchTerms = input.Split(' ');
    from b in books
    where b
    .InStore == true && b.Price > 10
    && (searchTerms.All(x => b.Title.Contains(x)))
    select b

    But i keep getting this error : Must specify parameter on right side of operation.
  2. Thomas
    Thomas avatar
    588 posts

    Posted 17 Apr 2012 Link to this post

    Hello Tys,

    please see this blog post that gives you some options and code that can be tweaked for your case.

    the Telerik team
    Share your passion about the Telerik Open Access by voting for Telerik's powerful ORM tool here >>
  3. DevCraft banner
Back to Top