0

Suppose I have a sequence of objects that I want to sort using the names of its properties, e.g. sequence IQueryable<T> to be sorted first by property A, then B, then C. I have the following code:

    using System.Linq.Dynamic.Core;

    IQueryable<T> source = ...
    var properties = new[]{"A","B","C"};
    foreach (var property in properties.Reverse())
    {
        source = source.OrderBy(property);
    }
    return source;

The resulting code returns source sorted only by the latest applied property (i.e. A in this case) disregarding all the previous orderings. Is it the expected behavior?

user2341923
  • 4,537
  • 6
  • 30
  • 44

0 Answers0