I’m trying to setup a query like this. So at first I’m selecting complete objects..
var values = (from p in Products
where p.LockedSince == null
select p);
Then optionally I’m adding extra where‘s
if(SupplierId > 0)
values = values.Where(p => p.SupplierId == SupplierId);
And in the end, I don’t need the complete product objects anymore, I just need a simple distinct and ordered list of one column (p.LocationName) .. something like this:
values = values.Select( p.LocationName ).Distinct().OrderBy(x => x);
I’ve tried something like Select(loc => new { p.LocationName }), but with no luck.
If you don’t need intermediate results more effective way would be to write single query