kendo-labs / dlinq-helpers

Add server paging, filtering and sorting via Dynamic Linq
71 stars 70 forks source link

Set the default order to the primary key #25

Open luizfbicalho opened 8 years ago

luizfbicalho commented 8 years ago

If the request doen't have an ordering, the entity framework returns an error to do the paging, so it could be better to set the default ordering to the Primary key of the entity if it doesn't have any order.

just like this, but getting the correct field using reflection

    if (request.Sort == null || request.Sort.Count() == 0)
    {
        var sort = new List<Sort>();
        sort.Add(new Sort() { Dir = "asc", Field = "Id" });
        request.Sort = sort;
    }
mshtawythug commented 7 years ago

I forked it and added a default sort to either Id or any other column that has Id in it or just the first column

https://github.com/mshtawythug/dlinq-helpers/tree/master/Kendo.DynamicLinq