OData / OData/AspNetCoreOData

Not found option parameters in function after uptdate from 7.4.1 to 7.5.8 / 7.5.9

Open
#286 15 comments 0 reactions 1 assignee View on GitHub

@habbes is already working on this.

Since Aug 26, 2021.

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

Description

After update Microsoft.AspNetCore.OData from 7.4.1 to 7.5.8 / 7.5.9 broken tests in my project

Situation 1

Declare Method in Edm

var book= builder.EntitySet<Book>("Books").EntityType;
      fn = book.Collection.Function("myfunc");
      fn.Parameter<System.DateTime?>("dateParam").Optional();
      fn.Parameter<string>("strParam").Optional();
      fn.Parameter<long?>("longParam1").Optional();
      fn.Parameter<long?>("longParam2").Optional();
      fn.ReturnsCollectionFromEntitySet<Book>("Books");

Method in contorller

[EnableQuery(AllowedQueryOptions =
      AllowedQueryOptions.All, MaxExpansionDepth = 10, MaxAnyAllExpressionDepth = 10
    )]
    [ODataRoute("myfunc(DateParam={dateParam},StrParam={strParam},LongParam1={longParam1},LongParam2={longParam2})")]
    [HttpGet]
    public IQueryable<Book> Myfunc([FromRoute] DateTime? dateParam, [FromRoute] string strParam, [FromRoute] long? longParam1, [FromRoute] long? longParam2) {
.....
}

Request: http://localhost:/5000:odata/Books/myfunc(dateParam=2020-11-06T09:33:14Z,strParam='Tmp',longParam1=null)
Error: Response status code does not indicate success: 404 (Not Found).

Situation 2
Declare Method in Edm

fn = messageClassFiltersEntity.Collection.Function("GetMessages");
      fn.Parameter<bool>("onlyNew").Optional();
      fn.ReturnsCollectionFromEntitySet<MessageReceiver>("MessageReceivers");

In controller

[HttpGet]
    [ODataRoute("GetMessages(onlyNew={onlyNew})")]
    public IQueryable<MessageReceiver> GetMessages(bool onlyNew) {}

Request: http://localhost:/5000:odata/MessageClassFilters/GetMessages()
Error: Response status code does not indicate success: 404 (Not Found)

Can you fix this bug and add tests for check it issue ?
Can you test it issue on 8 version and answer it is work or broken ?

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.