示例#1
0
        private IQueryable <XElement> ProcessOrder(string orderOption, IQueryable <XElement> iQueryable)
        {
            IQueryable <XElement> source = iQueryable;

            ParameterExpression[] it = new ParameterExpression[] { Expression.Parameter(source.ElementType, "") };

            DynamicQueryable.OGDIExpressionParser parser = new DynamicQueryable.OGDIExpressionParser(it, orderOption, null, ColumnsInformation.ToArray());

            IEnumerable <DynamicQueryable.DynamicOrdering> orderings = parser.ParseOrdering();
            Expression queryExpr  = source.Expression;
            string     methodAsc  = "OrderBy";
            string     methodDesc = "OrderByDescending";

            foreach (DynamicQueryable.DynamicOrdering o in orderings)
            {
                queryExpr = Expression.Call(
                    typeof(Queryable), o.Ascending ? methodAsc : methodDesc,
                    new Type[] { source.ElementType, o.Selector.Type },
                    queryExpr, Expression.Quote(Expression.Lambda(o.Selector, it)));
                methodAsc  = "ThenBy";
                methodDesc = "ThenByDescending";
            }

            IQueryable <XElement> result = (IQueryable <XElement>)source.Provider.CreateQuery(queryExpr);

            return(result);
        }
示例#2
0
        private IQueryable <XElement> ProcessFilter(string filterOption, IQueryable <XElement> iQueryable)
        {
            IQueryable <XElement> source = iQueryable;

            ParameterExpression[] it = new ParameterExpression[] { Expression.Parameter(source.ElementType, "") };

            DynamicQueryable.OGDIExpressionParser parser = new DynamicQueryable.OGDIExpressionParser(it, filterOption, null, ColumnsInformation.ToArray());

            LambdaExpression lambda = Expression.Lambda(parser.Parse(typeof(bool)), it);

            IQueryable <XElement> result = (IQueryable <XElement>)source.Provider.CreateQuery(
                Expression.Call(
                    typeof(Queryable), "Where",
                    new Type[] { source.ElementType },
                    source.Expression, Expression.Quote(lambda)));

            return(result);
        }
        private IQueryable<XElement> ProcessOrder(string orderOption, IQueryable<XElement> iQueryable)
        {
            IQueryable<XElement> source = iQueryable;
            ParameterExpression[] it = new ParameterExpression[] { Expression.Parameter(source.ElementType, "") };

            DynamicQueryable.OGDIExpressionParser parser = new DynamicQueryable.OGDIExpressionParser(it, orderOption, null, ColumnsInformation.ToArray());

            IEnumerable<DynamicQueryable.DynamicOrdering> orderings = parser.ParseOrdering();
            Expression queryExpr = source.Expression;
            string methodAsc = "OrderBy";
            string methodDesc = "OrderByDescending";
            foreach (DynamicQueryable.DynamicOrdering o in orderings)
            {
                queryExpr = Expression.Call(
                    typeof(Queryable), o.Ascending ? methodAsc : methodDesc,
                    new Type[] { source.ElementType, o.Selector.Type },
                    queryExpr, Expression.Quote(Expression.Lambda(o.Selector, it)));
                methodAsc = "ThenBy";
                methodDesc = "ThenByDescending";
            }

            IQueryable<XElement> result = (IQueryable<XElement>)source.Provider.CreateQuery(queryExpr);

            return result;
        }
        private IQueryable<XElement> ProcessFilter(string filterOption, IQueryable<XElement> iQueryable)
        {
            IQueryable<XElement> source = iQueryable;
            ParameterExpression[] it = new ParameterExpression[] { Expression.Parameter(source.ElementType, "") };

            DynamicQueryable.OGDIExpressionParser parser = new DynamicQueryable.OGDIExpressionParser(it, filterOption, null, ColumnsInformation.ToArray());

            LambdaExpression lambda = Expression.Lambda(parser.Parse(typeof(bool)), it);

            IQueryable<XElement> result = (IQueryable<XElement>)source.Provider.CreateQuery(
                Expression.Call(
                    typeof(Queryable), "Where",
                    new Type[] { source.ElementType },
                    source.Expression, Expression.Quote(lambda)));

            return result;
        }