示例#1
0
        public static IEnumerable <KeyValuePair <Expression, DocumentSortOrder> > CreateOrderExpression(Type type, InvocationQuerySyntaxNode node)
        {
            var visitor         = new ExpressionOrderQuerySyntaxVisitor(type);
            var orderProperties = (ConstantExpression)visitor.Visit(node);

            return((IEnumerable <KeyValuePair <Expression, DocumentSortOrder> >)orderProperties.Value);
        }
示例#2
0
        private IDictionary <Expression <Func <TDocument, object> >, DocumentSortOrder> BuildOrder(IHttpRequest request)
        {
            var orderMethods = ParseOrder(request);

            if (orderMethods != null)
            {
                var order = new Dictionary <Expression <Func <TDocument, object> >, DocumentSortOrder>();

                foreach (var orderMethod in orderMethods)
                {
                    var orderProperties = ExpressionOrderQuerySyntaxVisitor.CreateOrderExpression(typeof(TDocument), orderMethod);

                    if (orderProperties != null)
                    {
                        foreach (var orderProperty in orderProperties)
                        {
                            order.Add((Expression <Func <TDocument, object> >)orderProperty.Key, orderProperty.Value);
                        }
                    }
                }

                return(order);
            }

            return(null);
        }