From e4e6bebf8823f358dd2f210962334877fb09bb9d Mon Sep 17 00:00:00 2001 From: Sam Xu Date: Tue, 9 Jun 2020 11:51:23 -0700 Subject: [PATCH] Set the default of MaxTop to null --- src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs | 3 ++- .../Query/DefaultQuerySettings.cs | 2 +- .../Query/ModelBoundQuerySettings.cs | 5 +---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs index 855c47f5ae..40800670ce 100644 --- a/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs +++ b/src/Microsoft.AspNet.OData.Shared/Formatter/EdmLibHelpers.cs @@ -934,7 +934,8 @@ private static ModelBoundQuerySettings GetMergedPropertyQuerySettings( propertyTypeQuerySettings.PageSize; } - if (mergedQuerySettings.MaxTop == 0 && propertyTypeQuerySettings.MaxTop != 0) + if (!mergedQuerySettings.MaxTop.HasValue || + (mergedQuerySettings.MaxTop == 0 && propertyTypeQuerySettings.MaxTop != 0)) { mergedQuerySettings.MaxTop = propertyTypeQuerySettings.MaxTop; diff --git a/src/Microsoft.AspNet.OData.Shared/Query/DefaultQuerySettings.cs b/src/Microsoft.AspNet.OData.Shared/Query/DefaultQuerySettings.cs index 67685a2826..8204c3a55b 100644 --- a/src/Microsoft.AspNet.OData.Shared/Query/DefaultQuerySettings.cs +++ b/src/Microsoft.AspNet.OData.Shared/Query/DefaultQuerySettings.cs @@ -10,7 +10,7 @@ namespace Microsoft.AspNet.OData.Query /// public class DefaultQuerySettings { - private int? _maxTop = 0; + private int? _maxTop; /// /// Gets or sets a value indicating whether navigation property can be expanded. diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ModelBoundQuerySettings.cs b/src/Microsoft.AspNet.OData.Shared/Query/ModelBoundQuerySettings.cs index b3cce60858..c53e94d610 100644 --- a/src/Microsoft.AspNet.OData.Shared/Query/ModelBoundQuerySettings.cs +++ b/src/Microsoft.AspNet.OData.Shared/Query/ModelBoundQuerySettings.cs @@ -18,10 +18,7 @@ public class ModelBoundQuerySettings private Dictionary _orderByConfigurations = new Dictionary(); private Dictionary _filterConfigurations = new Dictionary(); - internal static ModelBoundQuerySettings DefaultModelBoundQuerySettings = new ModelBoundQuerySettings - { - _maxTop = 0 - }; + internal static ModelBoundQuerySettings DefaultModelBoundQuerySettings = new ModelBoundQuerySettings(); /// /// Instantiates a new instance of the class