예제 #1
0
        public QueryPaggedBase <TItem, TResult> AddSorting(Expression <Func <TItem, object> > memberSelector, bool desc = false)
        {
            if (_sorting == null)
            {
                _sorting = new SortingCollection();
            }
            _sorting.Add(SortingDescriptor.Get(memberSelector, desc));

            return(this);
        }
예제 #2
0
        void IQueryVisitor.Visit(SortingDescriptor sd)
        {
            Validator.ValidatePropertyName <T>(sd.Field);

            string ordAsc  = _isFirstItem ? "OrderBy" : "ThenBy";
            string ordDesc = _isFirstItem ? "OrderByDescending" : "ThenByDescending";

            _isFirstItem = false;

            Expression           propertyAccess = LinqExpressionHelper.GetMemberChainExpression(_param, sd.Field);
            LambdaExpression     orderByExp     = Expression.Lambda(propertyAccess, _param);
            MethodCallExpression resultExp      = Expression.Call(typeof(Queryable), sd.Desc ? ordDesc : ordAsc, new[] { _t, propertyAccess.Type },
                                                                  _query.Expression, Expression.Quote(orderByExp));

            _query = _query.Provider.CreateQuery <T>(resultExp);
        }
예제 #3
0
 void IQueryVisitor.Visit(SortingDescriptor fd)
 {
     _bld.AppendFormat("[{0}]{1}", fd.Field, fd.Desc ? " desc":string.Empty);
 }
예제 #4
0
 void IQueryVisitor.Visit(SortingDescriptor fd)
 {
     _bld.AppendFormat("[{0}]{1}", fd.Field, fd.Desc ? " desc":string.Empty);
 }