public string AddOrUpdate(string element) { var parse = Parse(element); if (parse == null) { return(ToString()); } var sort = new SortCollection <TSource>(ToString()); var property = sort.Properties.Find(x => x.PropertyName == parse.PropertyName); if (property == null) { sort.Properties.Add(parse); return(sort.ToString()); } property.Direction = property.Direction == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; return(sort.ToString()); }
public string Remove(string element) { var parse = Parse(element); if (parse == null) { return(ToString()); } var sort = new SortCollection <TSource>(ToString()); var property = sort.Properties.Find(x => x.PropertyName == parse.PropertyName); if (property != null) { sort.Properties.Remove(property); } return(sort.ToString()); }
public static IQueryable <TSource> OrderBy <TSource>(this IQueryable <TSource> queryable, string sorts, out SortCollection <TSource> sortCollection) { sortCollection = new SortCollection <TSource>(sorts); return(sortCollection.Apply(queryable)); }
public static IQueryable <TSource> OrderBy <TSource>(this IQueryable <TSource> queryable, params string[] sorts) { var sort = new SortCollection <TSource>(sorts); return(sort.Apply(queryable)); }