@@ -129,7 +129,7 @@ void VisitEnableQuery( IReadOnlyList<EnableQueryAttribute> attributes )
129129
130130 if ( attribute . AllowedArithmeticOperators == AllowedArithmeticOperators . None )
131131 {
132- attribute . AllowedArithmeticOperators = AllowedArithmeticOperators . None ;
132+ context . AllowedArithmeticOperators = AllowedArithmeticOperators . None ;
133133 }
134134 else
135135 {
@@ -138,7 +138,7 @@ void VisitEnableQuery( IReadOnlyList<EnableQueryAttribute> attributes )
138138
139139 if ( attribute . AllowedFunctions == AllowedFunctions . None )
140140 {
141- attribute . AllowedFunctions = AllowedFunctions . None ;
141+ context . AllowedFunctions = AllowedFunctions . None ;
142142 }
143143 else
144144 {
@@ -147,7 +147,7 @@ void VisitEnableQuery( IReadOnlyList<EnableQueryAttribute> attributes )
147147
148148 if ( attribute . AllowedLogicalOperators == AllowedLogicalOperators . None )
149149 {
150- attribute . AllowedLogicalOperators = AllowedLogicalOperators . None ;
150+ context . AllowedLogicalOperators = AllowedLogicalOperators . None ;
151151 }
152152 else
153153 {
@@ -156,7 +156,7 @@ void VisitEnableQuery( IReadOnlyList<EnableQueryAttribute> attributes )
156156
157157 if ( attribute . AllowedQueryOptions == AllowedQueryOptions . None )
158158 {
159- attribute . AllowedQueryOptions = AllowedQueryOptions . None ;
159+ AllowedQueryOptions = AllowedQueryOptions . None ;
160160 }
161161 else
162162 {
@@ -250,7 +250,12 @@ void VisitCount( ModelBoundQuerySettings querySettings )
250250 {
251251 Contract . Requires ( querySettings != null ) ;
252252
253- if ( querySettings . Countable == true )
253+ if ( ! querySettings . Countable . HasValue )
254+ {
255+ return ;
256+ }
257+
258+ if ( querySettings . Countable . Value )
254259 {
255260 AllowedQueryOptions |= Count ;
256261 }
@@ -348,22 +353,59 @@ void Visit<TSetting>(
348353
349354 foreach ( var property in allowedProperties )
350355 {
351- queryableProperties . Add ( property ) ;
356+ if ( ! queryableProperties . Contains ( property , comparer ) )
357+ {
358+ queryableProperties . Add ( property ) ;
359+ }
360+ }
361+ }
362+
363+ bool IsSelectEnabled ( ModelBoundQuerySettings querySettings )
364+ {
365+ if ( ! querySettings . DefaultSelectType . HasValue )
366+ {
367+ return AllowedQueryOptions . HasFlag ( Select ) ||
368+ querySettings . SelectConfigurations . Any ( p => p . Value != Disabled ) ;
369+ }
370+
371+ return querySettings . DefaultSelectType . Value != Disabled ||
372+ querySettings . SelectConfigurations . Any ( p => p . Value != Disabled ) ;
373+ }
374+
375+ bool IsExpandEnabled ( ModelBoundQuerySettings querySettings )
376+ {
377+ if ( ! querySettings . DefaultExpandType . HasValue )
378+ {
379+ return AllowedQueryOptions . HasFlag ( Expand ) ||
380+ querySettings . ExpandConfigurations . Any ( p => p . Value . ExpandType != Disabled ) ;
352381 }
382+
383+ return querySettings . DefaultExpandType . Value != Disabled ||
384+ querySettings . ExpandConfigurations . Any ( p => p . Value . ExpandType != Disabled ) ;
353385 }
354386
355- static bool IsSelectEnabled ( ModelBoundQuerySettings querySettings ) =>
356- ( querySettings . DefaultSelectType != null && querySettings . DefaultSelectType . Value != Disabled ) ||
357- querySettings . SelectConfigurations . Any ( p => p . Value != Disabled ) ;
387+ bool IsFilterEnabled ( ModelBoundQuerySettings querySettings )
388+ {
389+ if ( ! querySettings . DefaultEnableFilter . HasValue )
390+ {
391+ return AllowedQueryOptions . HasFlag ( Filter ) ||
392+ querySettings . FilterConfigurations . Any ( p => p . Value ) ;
393+ }
358394
359- static bool IsExpandEnabled ( ModelBoundQuerySettings querySettings ) =>
360- ( querySettings . DefaultExpandType != null && querySettings . DefaultExpandType . Value != Disabled ) ||
361- querySettings . ExpandConfigurations . Any ( p => p . Value . ExpandType != Disabled ) ;
395+ return querySettings . DefaultEnableFilter . Value ||
396+ querySettings . FilterConfigurations . Any ( p => p . Value ) ;
397+ }
362398
363- static bool IsFilterEnabled ( ModelBoundQuerySettings querySettings ) =>
364- querySettings . DefaultEnableFilter == true || querySettings . FilterConfigurations . Any ( p => p . Value ) ;
399+ bool IsOrderByEnabled ( ModelBoundQuerySettings querySettings )
400+ {
401+ if ( ! querySettings . DefaultEnableOrderBy . HasValue )
402+ {
403+ return AllowedQueryOptions . HasFlag ( OrderBy ) ||
404+ querySettings . OrderByConfigurations . Any ( p => p . Value ) ;
405+ }
365406
366- static bool IsOrderByEnabled ( ModelBoundQuerySettings querySettings ) =>
367- querySettings . DefaultEnableOrderBy == true || querySettings . OrderByConfigurations . Any ( p => p . Value ) ;
407+ return querySettings . DefaultEnableOrderBy . Value ||
408+ querySettings . OrderByConfigurations . Any ( p => p . Value ) ;
409+ }
368410 }
369411}
0 commit comments