diff --git a/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptions.cs b/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptions.cs
index b75bc39858..8bd18525e7 100644
--- a/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptions.cs
+++ b/src/Microsoft.AspNet.OData.Shared/Query/ODataQueryOptions.cs
@@ -40,8 +40,6 @@ public partial class ODataQueryOptions
private ODataQueryOptionParser _queryOptionParser;
- private AllowedQueryOptions _ignoreQueryOptions = AllowedQueryOptions.None;
-
private ETag _etagIfMatch;
private bool _etagIfMatchChecked;
@@ -150,6 +148,11 @@ private void Initialize(ODataQueryContext context)
///
public ODataQueryValidator Validator { get; set; }
+ ///
+ /// Gets or sets the query options that will be ignored.
+ ///
+ public AllowedQueryOptions IgnoreQueryOptions { get; set; }
+
///
/// Gets or sets the request headers.
///
@@ -290,7 +293,7 @@ public virtual IQueryable ApplyTo(IQueryable query)
/// The new after the query has been applied to.
public virtual IQueryable ApplyTo(IQueryable query, AllowedQueryOptions ignoreQueryOptions)
{
- _ignoreQueryOptions = ignoreQueryOptions;
+ this.IgnoreQueryOptions = ignoreQueryOptions;
return ApplyTo(query, new ODataQuerySettings());
}
@@ -301,10 +304,12 @@ public virtual IQueryable ApplyTo(IQueryable query, AllowedQueryOptions ignoreQu
/// The settings to use in query composition.
/// The query parameters that are already applied in queries.
/// The new after the query has been applied to.
- public virtual IQueryable ApplyTo(IQueryable query, ODataQuerySettings querySettings,
+ public virtual IQueryable ApplyTo(
+ IQueryable query,
+ ODataQuerySettings querySettings,
AllowedQueryOptions ignoreQueryOptions)
{
- _ignoreQueryOptions = ignoreQueryOptions;
+ this.IgnoreQueryOptions = ignoreQueryOptions;
return ApplyTo(query, querySettings);
}
@@ -530,8 +535,8 @@ private static void ExtractGroupingProperties(List result, IEnumerable
public virtual object ApplyTo(object entity, ODataQuerySettings querySettings, AllowedQueryOptions ignoreQueryOptions)
{
- _ignoreQueryOptions = ignoreQueryOptions;
- return ApplyTo(entity, new ODataQuerySettings());
+ this.IgnoreQueryOptions = ignoreQueryOptions;
+ return ApplyTo(entity, querySettings);
}
///
@@ -987,7 +992,7 @@ private void BuildQueryOptions(IDictionary queryParameters)
private bool IsAvailableODataQueryOption(object queryOption, AllowedQueryOptions queryOptionFlag)
{
- return ((queryOption != null) && ((_ignoreQueryOptions & queryOptionFlag) == AllowedQueryOptions.None));
+ return (queryOption != null) && ((this.IgnoreQueryOptions & queryOptionFlag) == AllowedQueryOptions.None);
}
private T ApplySelectExpand(T entity, ODataQuerySettings querySettings)
diff --git a/test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl b/test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl
index 2657d5a1d1..536da11d4d 100644
--- a/test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl
+++ b/test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl
@@ -2503,6 +2503,7 @@ public class Microsoft.AspNet.OData.Query.ODataQueryOptions {
FilterQueryOption Filter { public get; }
ETag IfMatch { public virtual get; }
ETag IfNoneMatch { public virtual get; }
+ AllowedQueryOptions IgnoreQueryOptions { public get; public set; }
OrderByQueryOption OrderBy { public get; }
ODataRawQueryOptions RawValues { public get; }
System.Net.Http.HttpRequestMessage Request { public get; }
diff --git a/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl b/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl
index eb7a0af4f1..c50a5e8f0d 100644
--- a/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl
+++ b/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl
@@ -2681,6 +2681,7 @@ public class Microsoft.AspNet.OData.Query.ODataQueryOptions {
FilterQueryOption Filter { public get; }
ETag IfMatch { public virtual get; }
ETag IfNoneMatch { public virtual get; }
+ AllowedQueryOptions IgnoreQueryOptions { public get; public set; }
OrderByQueryOption OrderBy { public get; }
ODataRawQueryOptions RawValues { public get; }
Microsoft.AspNetCore.Http.HttpRequest Request { public get; }
diff --git a/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore3x.OData.PublicApi.bsl b/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore3x.OData.PublicApi.bsl
index 14dd5669f8..ea76068c74 100644
--- a/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore3x.OData.PublicApi.bsl
+++ b/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore3x.OData.PublicApi.bsl
@@ -2856,6 +2856,7 @@ public class Microsoft.AspNet.OData.Query.ODataQueryOptions {
FilterQueryOption Filter { public get; }
ETag IfMatch { public virtual get; }
ETag IfNoneMatch { public virtual get; }
+ AllowedQueryOptions IgnoreQueryOptions { public get; public set; }
OrderByQueryOption OrderBy { public get; }
ODataRawQueryOptions RawValues { public get; }
Microsoft.AspNetCore.Http.HttpRequest Request { public get; }