You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with OData and I've encountered an issue when using the $compute and $select query options with properties of type array. Here's what I'm trying to achieve:
Query URL for Non-Array Property (Working):
http://host/odata/MyEntity?$compute=int as myint,string as mystring &$select=myint,mystring
This URL works as expected. It returns the myint and mystring properties in the response, replacing the original entity properties int and string.
Query URL for Array Property (Not Working):
http://host/odata/MyEntity?$compute=array as myarray&$select=myarray
This URL results in an error. I want to transform the array property into myarray in the response, similar to how it works with non-array properties.
Error Details:
I am receiving the following error when attempting the second query:
Error Message:
"Message": "Object reference not set to an instance of an object."
Stack Trace:
at Microsoft.OData.UriParser.ComputeBinder.BindComputeExpressionToken(ComputeExpressionTokentoken)
at Microsoft.OData.UriParser.ComputeBinder.BindCompute(ComputeToken token)
at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseComputeImplementation(String compute, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)
at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseCompute()
at Microsoft.AspNetCore.OData.Query.ComputeQueryOption.get_ComputeClause()
at Microsoft.AspNetCore.OData.Query.Validator.ComputeQueryValidator.Validate(ComputeQueryOption computeQueryOption, ODataValidationSettings validationSettings)
at Microsoft.AspNetCore.OData.Query.ComputeQueryOption.Validate(ODataValidationSettings validationSettings)
at Microsoft.AspNetCore.OData.Query.Validator.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)
at Microsoft.AspNetCore.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings)
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions)
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuting(ActionExecutingContext actionExecutingContext)
at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()--- End of stack trace from previous location ---\n
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()--- End of stack trace from previous location ---\n
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()--- End of stack trace from previous location ---\n
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext cont...
I'm working with OData and I've encountered an issue when using the $compute and $select query options with properties of type array. Here's what I'm trying to achieve:
Query URL for Non-Array Property (Working):
http://host/odata/MyEntity?$compute=int as myint,string as mystring &$select=myint,mystring
This URL works as expected. It returns the myint and mystring properties in the response, replacing the original entity properties int and string.
Query URL for Array Property (Not Working):
http://host/odata/MyEntity?$compute=array as myarray&$select=myarray
This URL results in an error. I want to transform the array property into myarray in the response, similar to how it works with non-array properties.
Error Details:
I am receiving the following error when attempting the second query:
Error Message:
"Message": "Object reference not set to an instance of an object."
Stack Trace:
Ported from Stackoverflow at here.
The text was updated successfully, but these errors were encountered: