Linq to SQL, how can I write an OR statement? RRS feed

  • Question

  • In the code below I am trying to return results from a database if any of the specified fields in my query match any of the search terms.
    Currently the linq query below only returns results where the search terms are found in ALL the where clauses but I need it to return the results if keywords match in
    field A OR field B OR field C shown below as keywords, sow and title. Essentially I just need to know how to use an OR statement using Linq? Any help is greatly appreciated. Thanks.

    List<string> search = new List<string>();
            char[] delimit = new char[] { ' ' };
            string phrase = tbSearch.Text.ToString();
            foreach (string substr in phrase.Split(delimit))
            TacitDataContext dc = new TacitDataContext();
               var projList = from p in dc.Projects
                              where search.Contains(p.Keywords)
                              where search.Contains(p.SOW)
                              where search.Contains(p.Title)
                              orderby p.DueDate
                              select new { p.Title, p.DueDate, p.Compensation, p.SOW};
    Friday, December 11, 2009 7:37 PM