Here is my try of dynamic Linq query with join. I try to get list of unique categories, brands and other criteria which were present in last reading in database. What is passed to the query (brand, category etc.) would only be defined at runtime.
I read about best way of doing this with func's, predicates etc., I think this is beyond my capacity at this stage. I'm trying the easier way with query string, which I got working for some simpler case, but I'm doing something wrong here with join. If I do just plain select product.Category
with intellisense of course this works, but not in string in select clause.
public IEnumerable<string> getFilterItems(string dbColumn)
{
var filterItems = new List<string>();
return (from reading in Helper.LatestReadings
where reading.Distributor != Helper.Client
join product in Helper.Context.Products
on reading.ProductId equals product.SkuCode
select ("product." + dbColumn)).Distinct();
}