Replies: 2 comments
-
I had the same issue, I solved it like this: |
Beta Was this translation helpful? Give feedback.
0 replies
-
Couple solutions are provided here |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
before asking, i've read this issue: OData/WebApi#1712
performing the request http://localhost/tf/dataapi/workspaces
returns
{
"@odata.context": "http://localhost/tf/dataapi/$metadata#Workspaces",
"value": [
{
"Label": "W 638271950392162608",
"Code": "W 638271950392162608",
"IsActive": true,
"Description": "Generated by Watin test",
"IsHidden": false,
"CreatedOn": "2023-08-09T16:23:59+03:00",
"LastModifiedOn": "2023-08-09T16:23:59+03:00",
"Id": 116
},
...
}
but performing the request
http://localhost/tf/dataapi/workspaces?apply=groupby((IsActive),aggregate($count as Total))
returns
[
{
"IsActive": true,
"Total": 309
},
{
"IsActive": false,
"Total": 1
}
]
so, in the second request @odata.context is missing and thus the structure of the response is different - only value is returned.
The controller method looks like this:
` [EnableQueryTopSkipFilter(AllowedQueryOptions = Select | Expand | Top | OrderBy | Count | Skip | Filter | Apply)]
[SwaggerResponse(Status200OK, "Objects successfully retrieved.", typeof(IEnumerable))]
public virtual async Task<ActionResult<IQueryable>> Get(ODataQueryOptions odataQueryOptions)
{
return await TryCatchAsync(async () =>
{
PagedCollectResult entities = await Entities.Get(odataQueryOptions);
the Page Method:
` protected OkObjectResult Page(PagedCollectResult paginatedQueryResult, ODataQueryOptions odataQueryOptions)
{
IReadOnlyList entities = paginatedQueryResult.Result;
So, return type of the Get method is ActionResult<...>, but not IQueryable<...>. I saw in exampleas, that @odata.context is returned in case when controller returns IQueriable<...>.
Is it possible to return odata.context in my case as well?
Or maybe you can suggest what I should modify in the EDM model?
Beta Was this translation helpful? Give feedback.
All reactions