Benny Sutton is 4 hire - just click here

Using PredicateBuilder to do an OR search

Here's a query you can run directly in LINQPad to create a conditional query using PredicateBuilder to do an OR search after splitting a string into words

Select language > C# Statements on the LINQpad menu, connect your database and specify the table/fields in the code below

             

        DataContext dataContext = this;
        string SearchTerm = "highland dancing young";
        string[] searchwords = SearchTerm.Split(' ');
        int wordcount = searchwords.Length;

        var predicate = PredicateBuilder.False<Photo>(); 
            foreach (string keyword in searchwords)
                     predicate = predicate.Or(p => p.Keywords.Contains(keyword));
    // take the first five records for brevity - an OR search will often return too many records!
			Photos.Where(predicate).Take(5).Dump();
            // Go to http://www.albahari.com/expressions/ for more info on PredicateBuilder.