dynamic OrderBy

23 views
Skip to first unread message

Pablo Tola

unread,
Mar 9, 2016, 6:17:30 PM3/9/16
to Simple.Data
Is there a way to dynamically add orderby clauses, for example:

foreach (var order in orderBy) {
     db.OrderBy(order.field);
}

and the continue paging, filtering, etc...

Richard Wilde

unread,
Mar 11, 2016, 9:23:07 AM3/11/16
to simpl...@googlegroups.com


  list = db.AuctionOnlineLots

                .All()

ApplySort();

…..

        private void ApplySort()

        {

            if (string.IsNullOrWhiteSpace(query.Sort)) return;

 

            if (query.SortDirection == 1)

                list = list.OrderBy(db[tableName][query.Sort]);

 

            if (query.SortDirection == 2)

                list = list.OrderByDescending(db[tableName][query.Sort]);

        }

HTH Rippo

--
You received this message because you are subscribed to the Google Groups "Simple.Data" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simpledata+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages