I am using the LinqKit PredicateBuilder (http://www.albahari.com/nutshell/predicatebuilder.aspx) for the method that performs the search. Here's how the relationships are built (Entity Framework 4 CPT 5 POCO):
public class MusicSheet { [Key] public int ID { get; set; } public string Title { get; set; } public string Key { get; set; } public virtual ICollection<Author> Authors { get; set; } } public class Author { [Key] public int ID { get; set; } public string Name { get; set; } public string Bio { get; set; } public virtual ICollection<MusicSheet> MusicSheets { get; set; } }
I need to create a predicate that checks MusicSheet (the Title contains a specific search term), as well as the Name or Bio author, which may also contain this search query, Here's what I have now:
var predicate = PredicateBuilder.False<MusicSheet>(); foreach (var term in terms) { string keyword = term; predicate = predicate .Or(s => s.Title.Contains(keyword));
Any suggestions? Thank you very much.
source share