Jak sortujecie dane w swoim kodzie? Założmy, że chciałby sortować produkty po nazwie i cenie:
private IQueryable<Product> SortProducts(IQueryable<Product> source, ProductSortingType type, SortDirection direction)
{
var ascending = direction == SortDirection.Ascending;
switch (type)
{
default:
case ProductSortingType.Name:
return ascending ? source.OrderBy(p => p.Name) : source.OrderByDescending(p => p.Name)
case ProductSortingType.Price:
return ascending ? source.OrderBy(p => p.Price) : source.OrderByDescending(p => p.Price);
}
}
Jak można by to lepiej zaimplementować?