@@ -1273,6 +1273,18 @@ public static IOrderedQueryable<TSource> OrderBy<TSource>([NotNull] this IQuerya
12731273 return OrderBy ( source , ParsingConfig . Default , ordering , args ) ;
12741274 }
12751275
1276+ // NEED TEXT!
1277+ public static IOrderedQueryable < TSource > OrderBy < TSource > ( [ NotNull ] this IQueryable < TSource > source , [ NotNull ] ParsingConfig config , [ NotNull ] string ordering , IComparer comparer , params object [ ] args )
1278+ {
1279+ return ( IOrderedQueryable < TSource > ) InternalOrderBy ( ( IQueryable ) source , config , ordering , comparer , args ) ;
1280+ }
1281+
1282+ // NEED TEXT!
1283+ public static IOrderedQueryable < TSource > OrderBy < TSource > ( [ NotNull ] this IQueryable < TSource > source , [ NotNull ] string ordering , IComparer comparer , params object [ ] args )
1284+ {
1285+ return OrderBy ( source , ParsingConfig . Default , ordering , comparer , args ) ;
1286+ }
1287+
12761288 /// <summary>
12771289 /// Sorts the elements of a sequence in ascending or descending order according to a key.
12781290 /// </summary>
@@ -1289,6 +1301,11 @@ public static IOrderedQueryable<TSource> OrderBy<TSource>([NotNull] this IQuerya
12891301 /// </code>
12901302 /// </example>
12911303 public static IOrderedQueryable OrderBy ( [ NotNull ] this IQueryable source , [ NotNull ] ParsingConfig config , [ NotNull ] string ordering , params object [ ] args )
1304+ {
1305+ return InternalOrderBy ( source , config , ordering , null , args ) ;
1306+ }
1307+
1308+ internal static IOrderedQueryable InternalOrderBy ( [ NotNull ] IQueryable source , [ NotNull ] ParsingConfig config , [ NotNull ] string ordering , IComparer comparer , params object [ ] args )
12921309 {
12931310 Check . NotNull ( source , nameof ( source ) ) ;
12941311 Check . NotNull ( config , nameof ( config ) ) ;
@@ -1302,10 +1319,22 @@ public static IOrderedQueryable OrderBy([NotNull] this IQueryable source, [NotNu
13021319
13031320 foreach ( DynamicOrdering dynamicOrdering in dynamicOrderings )
13041321 {
1305- queryExpr = Expression . Call (
1306- typeof ( Queryable ) , dynamicOrdering . MethodName ,
1307- new [ ] { source . ElementType , dynamicOrdering . Selector . Type } ,
1308- queryExpr , Expression . Quote ( Expression . Lambda ( dynamicOrdering . Selector , parameters ) ) ) ;
1322+ if ( comparer == null )
1323+ {
1324+ queryExpr = Expression . Call (
1325+ typeof ( Queryable ) , dynamicOrdering . MethodName ,
1326+ new [ ] { source . ElementType , dynamicOrdering . Selector . Type } ,
1327+ queryExpr , Expression . Quote ( Expression . Lambda ( dynamicOrdering . Selector , parameters ) ) ) ;
1328+ }
1329+ else
1330+ {
1331+ var comparerGenericType = typeof ( IComparer < > ) . MakeGenericType ( dynamicOrdering . Selector . Type ) ;
1332+ queryExpr = Expression . Call (
1333+ typeof ( Queryable ) , dynamicOrdering . MethodName ,
1334+ new [ ] { source . ElementType , dynamicOrdering . Selector . Type } ,
1335+ queryExpr , Expression . Quote ( Expression . Lambda ( dynamicOrdering . Selector , parameters ) ) ,
1336+ Expression . Constant ( comparer , comparerGenericType ) ) ;
1337+ }
13091338 }
13101339
13111340 var optimized = OptimizeExpression ( queryExpr ) ;
@@ -2176,6 +2205,18 @@ public static IOrderedQueryable<TSource> ThenBy<TSource>([NotNull] this IOrdered
21762205 {
21772206 return ThenBy ( source , ParsingConfig . Default , ordering , args ) ;
21782207 }
2208+
2209+ // NEED TEXT!
2210+ public static IOrderedQueryable < TSource > ThenBy < TSource > ( [ NotNull ] this IOrderedQueryable < TSource > source , [ NotNull ] ParsingConfig config , [ NotNull ] string ordering , IComparer comparer , params object [ ] args )
2211+ {
2212+ return ( IOrderedQueryable < TSource > ) InternalThenBy ( ( IOrderedQueryable ) source , config , ordering , comparer , args ) ;
2213+ }
2214+
2215+ // NEED TEXT!
2216+ public static IOrderedQueryable < TSource > ThenBy < TSource > ( [ NotNull ] this IOrderedQueryable < TSource > source , [ NotNull ] string ordering , IComparer comparer , params object [ ] args )
2217+ {
2218+ return ThenBy ( source , ParsingConfig . Default , ordering , comparer , args ) ;
2219+ }
21792220 /// <summary>
21802221 /// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
21812222 /// </summary>
@@ -2193,6 +2234,11 @@ public static IOrderedQueryable<TSource> ThenBy<TSource>([NotNull] this IOrdered
21932234 /// </code>
21942235 /// </example>
21952236 public static IOrderedQueryable ThenBy ( [ NotNull ] this IOrderedQueryable source , [ NotNull ] ParsingConfig config , [ NotNull ] string ordering , params object [ ] args )
2237+ {
2238+ return InternalThenBy ( source , config , ordering , null , args ) ;
2239+ }
2240+
2241+ internal static IOrderedQueryable InternalThenBy ( [ NotNull ] this IOrderedQueryable source , [ NotNull ] ParsingConfig config , [ NotNull ] string ordering , IComparer comparer , params object [ ] args )
21962242 {
21972243 Check . NotNull ( source , nameof ( source ) ) ;
21982244 Check . NotNull ( config , nameof ( config ) ) ;
@@ -2206,10 +2252,22 @@ public static IOrderedQueryable ThenBy([NotNull] this IOrderedQueryable source,
22062252
22072253 foreach ( DynamicOrdering dynamicOrdering in dynamicOrderings )
22082254 {
2209- queryExpr = Expression . Call (
2210- typeof ( Queryable ) , dynamicOrdering . MethodName ,
2211- new [ ] { source . ElementType , dynamicOrdering . Selector . Type } ,
2212- queryExpr , Expression . Quote ( Expression . Lambda ( dynamicOrdering . Selector , parameters ) ) ) ;
2255+ if ( comparer == null )
2256+ {
2257+ queryExpr = Expression . Call (
2258+ typeof ( Queryable ) , dynamicOrdering . MethodName ,
2259+ new [ ] { source . ElementType , dynamicOrdering . Selector . Type } ,
2260+ queryExpr , Expression . Quote ( Expression . Lambda ( dynamicOrdering . Selector , parameters ) ) ) ;
2261+ }
2262+ else
2263+ {
2264+ var comparerGenericType = typeof ( IComparer < > ) . MakeGenericType ( dynamicOrdering . Selector . Type ) ;
2265+ queryExpr = Expression . Call (
2266+ typeof ( Queryable ) , dynamicOrdering . MethodName ,
2267+ new [ ] { source . ElementType , dynamicOrdering . Selector . Type } ,
2268+ queryExpr , Expression . Quote ( Expression . Lambda ( dynamicOrdering . Selector , parameters ) ) ,
2269+ Expression . Constant ( comparer , comparerGenericType ) ) ;
2270+ }
22132271 }
22142272
22152273 var optimized = OptimizeExpression ( queryExpr ) ;
0 commit comments