I have the following function:
public List<TopMediansModel> QueryForMedians(string state, string median)
{
ApplicationDbContext db = new ApplicationDbContext();
return (from q in db.StateSuburbLocation
where (q.State == state)
orderby q.GetType().GetProperty(median) descending
select new TopMediansModel
{
Median = median,
MedianValue = q.GetType().GetProperty(median),
MedianSuburb = q.Suburb
}).Take(10).ToList();
}
Is it possible to have the orderby and MedianValue 'properties' as variables?
I've tried using the GetType().GetProperty() Methods, and am no doubt doing so incorrectly.