private static MethodInfo GetOrderByMethodInfo(Expression source, OrderByDirection direction, Type sourceType, Type keyType) { if (source.Type.GetGenericTypeDefinition() == typeof(IOrderedEnumerable <>)) { return(direction == OrderByDirection.Ascending ? OeMethodInfoHelper.GetThenByMethodInfo(sourceType, keyType) : OeMethodInfoHelper.GetThenByDescendingMethodInfo(sourceType, keyType)); } else { return(direction == OrderByDirection.Ascending ? OeMethodInfoHelper.GetOrderByMethodInfo(sourceType, keyType) : OeMethodInfoHelper.GetOrderByDescendingMethodInfo(sourceType, keyType)); } }