views:

98

answers:

0

I am using dynamic linq to make a generic class for processing a generic JqGrid from MVC all works fine (searching, pagination etc) except for sorting on code properties. Sorting works fine when I am hitting the DB to sort the data, but as soon as it is a property I have made the sorting does not work eg

 public partial class tblStockOrder
{
    public string approved
    {
        get
        {
            return approved_id == null ? "" : "Approved";
        }
    }
}

I am running the following Dynamic Linq

        items = items
            .OrderBy(string.Format("{0} {1}", sidx, sord))
            .Skip(pageIndex * pageSize)
            .Take(pageSize);

Where sidx etc are strings passed in by jquery.

So basically what is the best solution for handling a case where some properties will be from the db while others will be code properties (not sure of the correct naming). I can handle all this in code using reflection but would obviously like the DB to handle as much of the searching / sorting as possible without pulling in thousands of records and sorting through them in code using reflection.