Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
 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));
 }
Esempio n. 4
0
        public static IQueryable <TSource> OrderBy <TSource>(this IQueryable <TSource> queryable, params string[] sorts)
        {
            var sort = new SortCollection <TSource>(sorts);

            return(sort.Apply(queryable));
        }