AspNetCoreOData
AspNetCoreOData copied to clipboard
No way of supporting $count=true without EDM
Is there any rational behind $count=true not working with [EnableQuery] attribute? I am aware that I can achieve count support using EDM approach but I would prefer sticking to [EnableQuery] for its brevity.
Can you please shed some lights why this is not possible right now? Is this something we can expect to be added in the future?
@michalczerwinski Can you use the PageResult<T> in the controller when the request has $count=true query?
@xuzhg: thanks for replying.
I tried this approach and failed. 2 problems:
- when using custom
PageResultI didn't manage to get $select (column selection) to work.ODataQueryOptions.ApplyTois taking care of top,skip, etc. but no column projection - when returning new PageResult with NextLink and Count final response was always without those fields. I tried returning
PageResult(...)andOk(PageResult(...))
If it is any help I used Microsoft.AspNetCore.OData version 8.0.2 with .NET Core 6-rc.1
@michalczerwinski Check this comment https://github.com/OData/AspNetCoreOData/issues/247#issuecomment-1068883361 I have a sample project that works https://github.com/KenitoInc/AspNetCoreOData8Net6
I hope that helps you resolve your issue
I have a sample project that works https://github.com/KenitoInc/AspNetCoreOData8Net6
@KenitoInc the sample you provided seems to be relying on an EDM model. I think what OP wanted here was for it to work in the EDM-less flow.
It's 2022 Is there any solution to this problem?