@@ -28,48 +28,14 @@ private static MethodInfo ContainsMethod
28
28
}
29
29
}
30
30
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 ;
55
33
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 ;
60
36
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 ;
73
39
74
40
public static IQueryable < TSource > Sort < TSource > ( this IQueryable < TSource > source , IJsonApiContext jsonApiContext , List < SortQuery > sortQueries )
75
41
{
@@ -89,11 +55,6 @@ public static IQueryable<TSource> Sort<TSource>(this IQueryable<TSource> source,
89
55
90
56
public static IOrderedQueryable < TSource > Sort < TSource > ( this IQueryable < TSource > source , IJsonApiContext jsonApiContext , SortQuery sortQuery )
91
57
{
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
-
97
58
BaseAttrQuery attr ;
98
59
if ( sortQuery . IsAttributeOfRelationship )
99
60
attr = new RelatedAttrSortQuery ( jsonApiContext , sortQuery ) ;
@@ -107,11 +68,6 @@ public static IOrderedQueryable<TSource> Sort<TSource>(this IQueryable<TSource>
107
68
108
69
public static IOrderedQueryable < TSource > Sort < TSource > ( this IOrderedQueryable < TSource > source , IJsonApiContext jsonApiContext , SortQuery sortQuery )
109
70
{
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
-
115
71
BaseAttrQuery attr ;
116
72
if ( sortQuery . IsAttributeOfRelationship )
117
73
attr = new RelatedAttrSortQuery ( jsonApiContext , sortQuery ) ;
0 commit comments