Exemplo n.º 1
0
        public IEntitySubsequentOrderBuilder <T> OrderBy(IQueryable <T> source, OrderExpressionBase orderExpression)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (orderExpression == null)
            {
                throw new ArgumentNullException(nameof(orderExpression));
            }

            var selector = LookupSelector(orderExpression.GetSelector());

            if (selector == null)
            {
                _queryable = source.OrderBy(e => 1);
                return(this);
            }

            _queryable = orderExpression.IsDescending()
                ? source.OrderByDescending(selector)
                : source.OrderBy(selector);

            return(this);
        }
Exemplo n.º 2
0
        public IEntitySubsequentOrderBuilder <T> ThenOrderBy(OrderExpressionBase orderExpression)
        {
            if (_queryable == null || orderExpression == null)
            {
                return(this);
            }

            var selectorExpression = LookupSelector(orderExpression.GetSelector());

            if (selectorExpression == null)
            {
                return(this);
            }

            _queryable = orderExpression.IsDescending()
                ? _queryable.ThenByDescending(selectorExpression)
                : _queryable.ThenBy(selectorExpression);

            return(this);
        }