Пример #1
0
        private Expression ApplyThenBy(Expression source, OrderByClause thenByClause)
        {
            if (thenByClause == null)
            {
                return(source);
            }

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

            MethodInfo thenByMethodInfo = thenByClause.Direction == OrderByDirection.Ascending ?
                                          OeMethodInfoHelper.GetThenByMethodInfo(ParameterType, e.Type) :
                                          OeMethodInfoHelper.GetThenByDescendingMethodInfo(ParameterType, e.Type);
            MethodCallExpression thenByCall = Expression.Call(thenByMethodInfo, source, lambda);

            return(ApplyThenBy(thenByCall, thenByClause.ThenBy));
        }
 private static MethodInfo GetThenByMethodInfo(OrderByDirection direction, Type sourceType, Type keyType)
 {
     return(direction == OrderByDirection.Ascending ?
            OeMethodInfoHelper.GetThenByMethodInfo(sourceType, keyType) :
            OeMethodInfoHelper.GetThenByDescendingMethodInfo(sourceType, keyType));
 }