OData / OData/AspNetCoreOData

Adding condition :min(1) to route parameter breaks OData routing

Open
#1,352 3 comments 1 reaction 1 assignee View on GitHub

@xuzhg is already working on this.

Since Nov 19, 2024.

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

Description

Assemblies affected
.NET 9.0
Microsoft.AspNetCore.OData 9.1.0
Microsoft.OData.Core 8.21

Describe the bug
[ApiExplorerSettings(GroupName = "OData")]
[ODataRouteComponent("global")]
[Route("/odata/global")]
public class SystemDataTypeController(GlobalDbContext _db) : ODataController
{
[EnableQuery]
[HttpGet("SystemDataType")]
public IQueryable Get()
{
return _db.SystemDataTypes.AsNoTracking();
}

[EnableQuery]
[HttpGet("SystemDataType/{id:int}")] // <--------------------------------- This works, but id:int:min(1) breaks the routing
[HttpGet("SystemDataType({id:int:min(1)})")] <--------------------------- This works, with or without condition
public SingleResult<SystemDataType> GetById([FromRoute] uint id)
{
    return SingleResult.Create(_db.SystemDataTypes.Where(x => x.Id == id).AsNoTracking());
}

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.