@@ -28,48 +28,14 @@ private static MethodInfo ContainsMethod
2828 }
2929 }
3030
31- [ Obsolete ( "Use Sort method with IJsonApiContext parameter instead. New Sort method provides nested sorting." ) ]
32- public static IQueryable < TSource > Sort < TSource > ( this IQueryable < TSource > source , List < SortQuery > sortQueries )
33- {
34- if ( sortQueries == null || sortQueries . Count == 0 )
35- return source ;
36-
37- var orderedEntities = source . Sort ( sortQueries [ 0 ] ) ;
38-
39- if ( sortQueries . Count <= 1 )
40- return orderedEntities ;
41-
42- for ( var i = 1 ; i < sortQueries . Count ; i ++ )
43- orderedEntities = orderedEntities . Sort ( sortQueries [ i ] ) ;
44-
45- return orderedEntities ;
46- }
47-
48- [ Obsolete ( "Use Sort method with IJsonApiContext parameter instead. New Sort method provides nested sorting." ) ]
49- public static IOrderedQueryable < TSource > Sort < TSource > ( this IQueryable < TSource > source , SortQuery sortQuery )
50- {
51- // For clients using SortQuery constructor with string based parameter
52- if ( sortQuery . SortedAttribute == null )
53- throw new JsonApiException ( 400 , $ "It's not possible to provide { nameof ( SortQuery ) } without { nameof ( SortQuery . SortedAttribute ) } parameter." +
54- $ " Use Sort method with IJsonApiContext parameter instead.") ;
31+ [ Obsolete ( "Use overload Sort<T>(IJsonApiContext, List<SortQuery>) instead." , error : true ) ]
32+ public static IQueryable < TSource > Sort < TSource > ( this IQueryable < TSource > source , List < SortQuery > sortQueries ) => null ;
5533
56- return sortQuery . Direction == SortDirection . Descending
57- ? source . OrderByDescending ( sortQuery . SortedAttribute . InternalAttributeName )
58- : source . OrderBy ( sortQuery . SortedAttribute . InternalAttributeName ) ;
59- }
34+ [ Obsolete ( "Use overload Sort<T>(IJsonApiContext, SortQuery) instead." , error : true ) ]
35+ public static IOrderedQueryable < TSource > Sort < TSource > ( this IQueryable < TSource > source , SortQuery sortQuery ) => null ;
6036
61- [ Obsolete ( "Use Sort method with IJsonApiContext parameter instead. New Sort method provides nested sorting." ) ]
62- public static IOrderedQueryable < TSource > Sort < TSource > ( this IOrderedQueryable < TSource > source , SortQuery sortQuery )
63- {
64- // For clients using SortQuery constructor with string based parameter
65- if ( sortQuery . SortedAttribute == null )
66- throw new JsonApiException ( 400 , $ "It's not possible to provide { nameof ( SortQuery ) } without { nameof ( SortQuery . SortedAttribute ) } parameter." +
67- $ " Use Sort method with IJsonApiContext parameter instead.") ;
68-
69- return sortQuery . Direction == SortDirection . Descending
70- ? source . ThenByDescending ( sortQuery . SortedAttribute . InternalAttributeName )
71- : source . ThenBy ( sortQuery . SortedAttribute . InternalAttributeName ) ;
72- }
37+ [ Obsolete ( "Use overload Sort<T>(IJsonApiContext, SortQuery) instead." , error : true ) ]
38+ public static IOrderedQueryable < TSource > Sort < TSource > ( this IOrderedQueryable < TSource > source , SortQuery sortQuery ) => null ;
7339
7440 public static IQueryable < TSource > Sort < TSource > ( this IQueryable < TSource > source , IJsonApiContext jsonApiContext , List < SortQuery > sortQueries )
7541 {
@@ -89,11 +55,6 @@ public static IQueryable<TSource> Sort<TSource>(this IQueryable<TSource> source,
8955
9056 public static IOrderedQueryable < TSource > Sort < TSource > ( this IQueryable < TSource > source , IJsonApiContext jsonApiContext , SortQuery sortQuery )
9157 {
92- // For clients using constructor with AttrAttribute parameter
93- if ( sortQuery . SortedAttribute != null )
94- throw new JsonApiException ( 400 , $ "It's not possible to provide { nameof ( SortQuery ) } with { nameof ( SortQuery . SortedAttribute ) } parameter." +
95- $ " Use { nameof ( SortQuery ) } constructor overload based on string attribute.") ;
96-
9758 BaseAttrQuery attr ;
9859 if ( sortQuery . IsAttributeOfRelationship )
9960 attr = new RelatedAttrSortQuery ( jsonApiContext , sortQuery ) ;
@@ -107,11 +68,6 @@ public static IOrderedQueryable<TSource> Sort<TSource>(this IQueryable<TSource>
10768
10869 public static IOrderedQueryable < TSource > Sort < TSource > ( this IOrderedQueryable < TSource > source , IJsonApiContext jsonApiContext , SortQuery sortQuery )
10970 {
110- // For clients using constructor with AttrAttribute parameter
111- if ( sortQuery . SortedAttribute != null )
112- throw new JsonApiException ( 400 , $ "It's not possible to provide { nameof ( SortQuery ) } with { nameof ( SortQuery . SortedAttribute ) } parameter." +
113- $ " Use { nameof ( SortQuery ) } constructor overload based on string attribute.") ;
114-
11571 BaseAttrQuery attr ;
11672 if ( sortQuery . IsAttributeOfRelationship )
11773 attr = new RelatedAttrSortQuery ( jsonApiContext , sortQuery ) ;
0 commit comments