public virtual void ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions) { if (request == null) { throw Error.ArgumentNull("request"); } if (queryOptions == null) { throw Error.ArgumentNull("queryOptions"); } IQueryCollection queryParameters = request.Query; foreach (var kvp in queryParameters) { if (!queryOptions.IsSupportedQueryOption(kvp.Key) && kvp.Key.StartsWith("$", StringComparison.Ordinal)) { // we don't support any custom query options that start with $ // this should be caught be OnActionExecuted(). throw new ArgumentOutOfRangeException(kvp.Key); } } queryOptions.Validate(_validationSettings); }
/// <summary> /// Validates the OData query in the incoming request. By default, the implementation throws an exception if /// the query contains unsupported query parameters. Override this method to perform additional validation of /// the query. /// </summary> /// <param name="request">The incoming request.</param> /// <param name="queryOptions"> /// The <see cref="ODataQueryOptions"/> instance constructed based on the incoming request. /// </param> public virtual void ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions) { if (request == null) { throw Error.ArgumentNull(nameof(request)); } if (queryOptions == null) { throw Error.ArgumentNull(nameof(queryOptions)); } IQueryCollection queryParameters = request.Query; foreach (var kvp in queryParameters) { if (!queryOptions.IsSupportedQueryOption(kvp.Key) && kvp.Key.StartsWith("$", StringComparison.Ordinal)) { // we don't support any custom query options that start with $ // this should be caught be OnActionExecuted(). throw new ODataException(Error.Format(SRResources.CustomQueryOptionNotSupportedWithDollarSign, kvp.Key)); } } queryOptions.Validate(_validationSettings); }