OData / OData/AspNetCoreOData

Cannot use $count with ODataRoute Attribute

Open
#69 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

investigated
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

Using the ODataRoute atrribute makes the $count not work.

/// Startup.cs
app.UseOData("odata", "odata", GetEdmModel());

static GetEdmModel()
{
    ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
    builder.EntitySet<User>("User");
    builder.EntitySet<User>("Product");
    return builder.GetEdmModel();
}
/// MyController.cs
[EnableQuery]
[ODataRoute("User")]
public IQueryable<User> GetUser() => User.GetQuery());

[EnableQuery]
[ODataRoute("Product")]
public IQueryable<Product> GetProduct() => Product.GetQuery());
http://localhost:5901/odata/User (Works)
http://localhost:5901/odata/User/$count (Not Working)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the OData setup in Startup.cs and the ODataRoute actions in MyController.cs. Run the listed /odata/User and /odata/User/$count requests to reproduce the discrepancy, then verify that the $count endpoint works while retaining the attribute-based routes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.