Esempio n. 1
0
        public Expression ApplyOrderBy(Expression source, OrderByClause orderByClause)
        {
            if (orderByClause == null)
            {
                return(source);
            }

            Expression       e      = _visitor.TranslateNode(orderByClause.Expression);
            LambdaExpression lambda = Expression.Lambda(e, Parameter);

            MethodInfo orderByMethodInfo = orderByClause.Direction == OrderByDirection.Ascending ?
                                           OeMethodInfoHelper.GetOrderByMethodInfo(ParameterType, e.Type) :
                                           OeMethodInfoHelper.GetOrderByDescendingMethodInfo(ParameterType, e.Type);
            MethodCallExpression orderByCall = Expression.Call(orderByMethodInfo, source, lambda);

            return(ApplyThenBy(orderByCall, orderByClause.ThenBy));
        }
 private static MethodInfo GetOrderByMethodInfo(OrderByDirection direction, Type sourceType, Type keyType)
 {
     return(direction == OrderByDirection.Ascending ?
            OeMethodInfoHelper.GetOrderByMethodInfo(sourceType, keyType) :
            OeMethodInfoHelper.GetOrderByDescendingMethodInfo(sourceType, keyType));
 }