odata.net icon indicating copy to clipboard operation
odata.net copied to clipboard

Filter on nullable DateOnly seems not supported

Open ArnaudB88 opened this issue 11 months ago • 4 comments

I want to filter on a nullable DateOnly type field. Currently this throws an exception.

Assemblies affected

Microsoft.OData.Core.dll v7.20

Reproduce steps

  • have a sql database with a table with a nullable Date field
  • this is mapped to a .NET class with a property type DateOnly? since .NET8 is used
  • execute a query which filters on the nullable DateOnly field eg StartDate ge 2024-03-29

Expected result

Query would return a result

Actual result

I am getting the following error:

Microsoft.OData.ODataException: A binary operator with incompatible types was detected. Found operand types 'System.Nullable_1OfDateOnly' and 'Edm.Date' for operator kind 'GreaterThanOrEqual'.

  Stack Trace: 
BinaryOperatorBinder.PromoteOperandTypes(BinaryOperatorKind binaryOperatorKind, SingleValueNode& left, SingleValueNode& right, TypeFacetsPromotionRules facetsPromotionRules)
ODataUriResolver.PromoteBinaryOperandTypes(BinaryOperatorKind binaryOperatorKind, SingleValueNode& leftNode, SingleValueNode& rightNode, IEdmTypeReference& typeReference)
StringAsEnumResolver.PromoteBinaryOperandTypes(BinaryOperatorKind binaryOperatorKind, SingleValueNode& leftNode, SingleValueNode& rightNode, IEdmTypeReference& typeReference)
BinaryOperatorBinder.BindBinaryOperator(BinaryOperatorToken binaryOperatorToken)
MetadataBinder.BindBinaryOperator(BinaryOperatorToken binaryOperatorToken)
MetadataBinder.Bind(QueryToken token)
...

Additional detail

This is possibly related with the feature request #2293

ArnaudB88 avatar Mar 29 '24 08:03 ArnaudB88