linq - LinqKit PredicateBuilder with EF 4 CPT 5 table relationships? -
i'm using linqkit predicatebuilder (http://www.albahari.com/nutshell/predicatebuilder.aspx) method searching. how relationships 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 able build predicate checks musicsheet
(the title
contains specific search term) name
or bio
of author might contain search term. here have:
var predicate = predicatebuilder.false<musicsheet>(); foreach (var term in terms) { string keyword = term; predicate = predicate .or(s => s.title.contains(keyword)); // todo check author name & bio }
any suggestions? thank much.
have tried this:
var predicate = predicatebuilder.false<musicsheet>(); foreach (var term in terms) { string keyword = term; predicate = predicate .or(s => s.title.contains(keyword) || s.authors.any (a => a.name.contains(keyword) || a.bio.contains(keyword))); }
Comments
Post a Comment