public static DbSelectExpression RemoveOrderExpression(this DbSelectExpression select, DbOrderExpression ordering)
        {
            if (select.OrderBy != null && select.OrderBy.Count > 0)
            {
                var orderby = new List <DbOrderExpression>(select.OrderBy);

                if (orderby != null)
                {
                    orderby.Remove(ordering);
                }

                return(select.SetOrderBy(orderby));
            }

            return(select);
        }
        public static DbSelectExpression AddOrderExpression(this DbSelectExpression select, DbOrderExpression ordering)
        {
            var orderby = new List <DbOrderExpression>();

            if (select.OrderBy != null)
            {
                orderby.AddRange(select.OrderBy);
            }

            if (orderby != null)
            {
                orderby.Add(ordering);
            }

            return(select.SetOrderBy(orderby));
        }