DateTime not being parsed correctly for functions.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Version:
Microsoft.AspNetCore.OData v8.0.10
Description:
DateTime not being parsed correctly for functions.
Steps to Reproduce
Add a function with DateTime parameters. Example:
var getAvailabilityFunction = builder.EntityType<TourPackage>().Collection.Function("GetAvailability");
getAvailabilityFunction.Parameter<Guid>("tourPackageId");
getAvailabilityFunction.Parameter<string>("hotelName");
getAvailabilityFunction.Parameter<DateTime>("dateFrom");
getAvailabilityFunction.Parameter<DateTime>("dateTo");
getAvailabilityFunction.ReturnsCollection<TourPackageAvailable>();
Implement it:
public async Task<IActionResult> GetAvailability(
ODataQueryOptions<TourPackageAvailable> options,
[FromODataUri] Guid tourPackageId,
[FromODataUri] string hotelName,
[FromODataUri] DateTime dateFrom,
[FromODataUri] DateTime dateTo)
{
// etc
Try to use it:
/odata/TourPackageApi/Default.GetAvailability(tourPackageId=4cc24078-a1ad-4ec5-abfc-29b8ef535f41,hotelName='Brim%20Hotel%20Tbilisi%204*',dateFrom=2022-05-08,dateTo=2022-05-09)
Result:
Notice the month and day are the wrong way around.
Try with adding time as well (just in case):
/odata/TourPackageApi/Default.GetAvailability(tourPackageId=4cc24078-a1ad-4ec5-abfc-29b8ef535f41,hotelName='Brim%20Hotel%20Tbilisi%204*',dateFrom=2022-05-08T00:00:00Z,dateTo=2022-05-09T00:00:00Z)
Same result.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two GetAvailability requests from the issue against Microsoft.AspNetCore.OData v8.0.10, then trace DateTime parameter binding for OData functions. Done means dateFrom and dateTo preserve their intended month and day values for both date-only and UTC date-time inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100