コード例 #1
0
        public static bool TryParse(string value, out SortParameter parameter)
        {
            try
            {
                parameter = Parse(value);
            }
            catch (Exception)
            {
                parameter = null;
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public static IQueryable <T> Sort <T>(this IQueryable <T> query, params string[] propertyNames)
        {
            if (propertyNames.Empty())
            {
                return(query);
            }

            var list = new List <SortParameter>();

            foreach (var name in propertyNames)
            {
                SortParameter parameter;
                if (SortParameter.TryParse(name, out parameter))
                {
                    list.Add(parameter);
                }
            }

            var sortParameterList = new SortParameterList(list);

            return(sortParameterList.Sort(query) as IQueryable <T>);
        }