Exemplo n.º 1
0
        public static PropertyInfo GetOrderByFromExpression(Expression expression)
        {
            var visitor = new OrderByPropertyInfoVisitor();

            visitor.Visit(expression);
            return(visitor.Property);
        }
Exemplo n.º 2
0
        public override Expression Visit(Expression node)
        {
            var methodCall = node as MethodCallExpression;

            if (methodCall != null && (methodCall.Method.Name == "OrderBy" || methodCall.Method.Name == "OrderByDescending"))
            {
                var visitor = new OrderByPropertyInfoVisitor();
                visitor.Visit(methodCall);
                if (visitor.Property != null)
                {
                    OrderedProperties.Add(visitor.Property);
                }
            }
            return(base.Visit(node));
        }