I have a Web API OData v4 service that I've created. I'm trying to create a bound function that has a TimeSpan parameter having a signature defined in the OData controller similar to the below:
public IQueryable<ProductionRecordDTO> GetProduction( [FromODataUri]DateTimeOffset startDate, [FromODataUri]DateTimeOffset endDate, [FromODataUri]TimeSpan sampleInterval)
It is configured in the OData model builder as below:
var getProduction = builder.EntitySet<ProductDTO>("Products").EntityType.Collection.Function("GetProduction"); getProduction.Namespace="ProductsService"; getProduction.ReturnsCollection<ProductionRecordDTO>(); getProduction.Parameter<DateTimeOffset>("StartDate"); getProduction.Parameter<DateTimeOffset>("EndDate"); getProduction.Parameter<TimeSpan>("SampleInterval");
When run, the model is seemingly properly created, the metadata description show that the "SampleInterval" is properly defined as an Edm.Duration type.
When I attempt to call this method however with a URL such as:
http://dev-pc/odata/Products/ProductsService.GetProduction(StartDate=2014-01-01T00:00:00Z, EndDate=2017-01-01T00:00:00Z, SampleInterval=P1Y)
An ODataException is thrown with the message 'SampleInterval=P1Y' is not in scope. The same is true for every ISO 8601 duration format variation I give it.
Using:
- Microsoft.OData.Core - v6.15.0
- Microsoft.AspNet.OData - v5.9.1
Any assistance offered would be greatly appreciated.