@@ -12,7 +12,7 @@ public EnableQueryAttribute(int maxTop, int maxPropertyMappingDepth = 5)
1212 var options = new QueryOptions ( )
1313 {
1414 MaxTop = maxTop ,
15- MaxPropertyMappingDepth = maxPropertyMappingDepth
15+ MaxPropertyMappingDepth = maxPropertyMappingDepth ,
1616 } ;
1717
1818 _options = options ;
@@ -25,10 +25,12 @@ public override void OnActionExecuting(ActionExecutingContext context) { }
2525 public override void OnActionExecuted ( ActionExecutedContext context )
2626 {
2727 var result = context . Result as ObjectResult ;
28- if ( result is null ) return ;
28+ if ( result is null )
29+ return ;
2930
3031 var queryable = result . Value as IQueryable < T > ;
31- if ( queryable is null ) return ;
32+ if ( queryable is null )
33+ return ;
3234
3335 var queryString = context . HttpContext . Request . Query ;
3436
@@ -37,7 +39,9 @@ public override void OnActionExecuted(ActionExecutedContext context)
3739
3840 if ( ! int . TryParse ( topQuery . ToString ( ) , out int top ) && ! string . IsNullOrEmpty ( topQuery ) )
3941 {
40- context . Result = new BadRequestObjectResult ( new { Message = "The query parameter 'Top' could not be parsed to an integer" } ) ;
42+ context . Result = new BadRequestObjectResult (
43+ new { Message = "The query parameter 'Top' could not be parsed to an integer" }
44+ ) ;
4145 return ;
4246 }
4347
@@ -47,7 +51,9 @@ public override void OnActionExecuted(ActionExecutedContext context)
4751
4852 if ( ! int . TryParse ( skipString , out int skip ) && ! string . IsNullOrEmpty ( skipQuery ) )
4953 {
50- context . Result = new BadRequestObjectResult ( new { Message = "The query parameter 'Skip' could not be parsed to an integer" } ) ;
54+ context . Result = new BadRequestObjectResult (
55+ new { Message = "The query parameter 'Skip' could not be parsed to an integer" }
56+ ) ;
5157 return ;
5258 }
5359
@@ -57,7 +63,9 @@ public override void OnActionExecuted(ActionExecutedContext context)
5763
5864 if ( ! bool . TryParse ( countString , out bool count ) && ! string . IsNullOrEmpty ( countString ) )
5965 {
60- context . Result = new BadRequestObjectResult ( new { Message = "The query parameter 'Count' could not be parsed to a boolean" } ) ;
66+ context . Result = new BadRequestObjectResult (
67+ new { Message = "The query parameter 'Count' could not be parsed to a boolean" }
68+ ) ;
6169 return ;
6270 }
6371
@@ -78,30 +86,34 @@ public override void OnActionExecuted(ActionExecutedContext context)
7886 Count = count ,
7987 OrderBy = orderbyQuery . ToString ( ) ,
8088 Search = search ,
81- Filter = filterQuery . ToString ( )
89+ Filter = filterQuery . ToString ( ) ,
8290 } ;
8391
8492 ISearchBinder < T > ? searchBinder = null ;
8593
8694 if ( ! string . IsNullOrEmpty ( search ) )
8795 {
88- searchBinder = context . HttpContext . RequestServices . GetService ( typeof ( ISearchBinder < T > ) ) as ISearchBinder < T > ;
96+ searchBinder =
97+ context . HttpContext . RequestServices . GetService ( typeof ( ISearchBinder < T > ) )
98+ as ISearchBinder < T > ;
8999 }
90100
91101 var applyOptions = _options ?? new QueryOptions ( ) ;
92102
93103 // Auto-resolve JsonNamingPolicy from DI if not explicitly set
94104 if ( applyOptions . PropertyNamingPolicy is null )
95105 {
96- var jsonOptions = context . HttpContext . RequestServices . GetService < IOptions < JsonOptions > > ( ) ;
106+ var jsonOptions = context . HttpContext . RequestServices . GetService <
107+ IOptions < JsonOptions >
108+ > ( ) ;
97109 var namingPolicy = jsonOptions ? . Value ? . JsonSerializerOptions ? . PropertyNamingPolicy ;
98110 if ( namingPolicy is not null )
99111 {
100112 applyOptions = new QueryOptions ( )
101113 {
102114 MaxTop = applyOptions . MaxTop ,
103115 MaxPropertyMappingDepth = applyOptions . MaxPropertyMappingDepth ,
104- PropertyNamingPolicy = namingPolicy
116+ PropertyNamingPolicy = namingPolicy ,
105117 } ;
106118 }
107119 }
@@ -110,10 +122,14 @@ public override void OnActionExecuted(ActionExecutedContext context)
110122 if ( applyResult . IsFailed )
111123 {
112124 var message = string . Join ( ", " , applyResult . Errors . Select ( x => x . Message ) ) ;
113- context . Result = new BadRequestObjectResult ( new { message , errors = applyResult . Errors } ) ;
125+ context . Result = new BadRequestObjectResult (
126+ new { message , errors = applyResult . Errors }
127+ ) ;
114128 return ;
115129 }
116130
117- context . Result = new OkObjectResult ( new PagedResponse < T > ( applyResult . Value . Query . ToList ( ) , applyResult . Value . Count ) ) ;
131+ context . Result = new OkObjectResult (
132+ new PagedResponse < T > ( applyResult . Value . Query . ToList ( ) , applyResult . Value . Count )
133+ ) ;
118134 }
119- }
135+ }
0 commit comments