Ok,
I have to build a predicate to select an unknown number of columns from a known entity in EF5 AND filter by an unknown number of columns ONE of which will always be a name from a child collection.
So this is what I need to end up with
var q = db.Set<Entity>()
.Where(e => e.Code.Contains("q") || e.Translations.FirstOrDefault(t => t.Culture.ID == "whatever").Description.Contains("q"))
.Select(e => new
{
e.ID,
e.Code,
Name = e.Translations.FirstOrDefault(t => t.Culture.ID == "whatever").Description
});
but I'm not sure how to approach building the predicate for the expression
e.Translations.FirstOrDefault(t => t.Culture.ID == "whatever").Description.Contains("q")
The columns to select and the fields to filter on are supplied as an array of strings, and in this instance the filter is always contains.
I'm familiar with building predicates, that's not the issue, it's more I've never had to look into child collections before and I'm at a total "WTF" point of the day :-)
Any and all pushes in the right direction would be most appriciated.