-1

I have an IEnumerable for multiple sort order specification where:

public class Specification
{
    public string Column { get; set; }
    public OrderByDirection Direction { get; set; }
    public int Priority { get; set; }
}   

Then I have another IQueryable that I would like to lazy sort on the basis of the given IEnumerable respecting the direction and the priority. What would be the best approach to do this? are there any libraries out there that currently do this? Can someone explain how something like this can be approached with dynamic queries (expression trees)?

Note: Assume the column specified do exist in the IQueryable.

dave.2
  • 483
  • 5
  • 12
D.S.
  • 289
  • 1
  • 13

1 Answers1

0

using Linq; i would create Lists of based on their priority and then foreach Priority List sort them the way you want to later add them all to one list

List l = [ArrayObject/List].OrderBy(o => o.Priority == (int)p);

  • use struct's instead of classes and don't use the get; set; this will improve performance a lot if you don't require it.
CorrupD
  • 36
  • 6