Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidCastException when filtering on nullable value types #260

Open
marcasburnett opened this issue Jan 23, 2025 · 0 comments
Open

InvalidCastException when filtering on nullable value types #260

marcasburnett opened this issue Jan 23, 2025 · 0 comments

Comments

@marcasburnett
Copy link

marcasburnett commented Jan 23, 2025

I have a type with nullable DateTime properties, which in some cases I need to add to my FilterCondition. When I do that, I get the error below. It looks like this is because NullableValueTypeDdbConverter inherits from DdbConverter but changes the nullability of the type parameter, which for value types means a totally different type.

Unable to cast object of type 'EfficientDynamoDb.Internal.Converters.NullableValueTypeDdbConverter1[System.DateTime]' to type 'EfficientDynamoDb.Converters.DdbConverter1[System.DateTime]'.
at EfficientDynamoDb.FluentCondition.Core.FilterBase1.GetPropertyConverter[TProperty](DdbExpressionVisitor visitor, Boolean useSize) at EfficientDynamoDb.FluentCondition.Operators.Common.FilterLessThan2.WriteAttributeValues(DdbWriter& writer, DynamoDbContextMetadata metadata, Int32& valuesCount, DdbExpressionVisitor visitor)
at EfficientDynamoDb.FluentCondition.Core.FilterOrWrapper.WriteAttributeValues(DdbWriter& writer, DynamoDbContextMetadata metadata, Int32& valuesCount, DdbExpressionVisitor visitor)
at EfficientDynamoDb.FluentCondition.Core.FilterOrWrapper.WriteAttributeValues(DdbWriter& writer, DynamoDbContextMetadata metadata, Int32& valuesCount, DdbExpressionVisitor visitor)
at EfficientDynamoDb.FluentCondition.Core.FilterAndWrapper.WriteAttributeValues(DdbWriter& writer, DynamoDbContextMetadata metadata, Int32& valuesCount, DdbExpressionVisitor visitor)
at EfficientDynamoDb.Internal.Extensions.Utf8JsonWriterExtensions.WriteConditionExpression(DdbWriter& writer, NoAllocStringBuilder& builder, DdbExpressionVisitor visitor, FilterBase condition, DynamoDbContextMetadata metadata)
at EfficientDynamoDb.Internal.Extensions.Utf8JsonWriterExtensions.WriteConditionExpression(DdbWriter& writer, FilterBase condition, DynamoDbContextMetadata metadata)
at EfficientDynamoDb.Internal.Operations.PutItem.PutItemHighLevelHttpContent.WriteDataAsync(DdbWriter ddbWriter)
at EfficientDynamoDb.Internal.Operations.Shared.DynamoDbHttpContent.SerializeToStreamAsync(Stream stream, TransportContext context)
at EfficientDynamoDb.Internal.Operations.Shared.DynamoDbHttpContent.SerializeToStreamAsync(Stream stream, TransportContext context)
at EfficientDynamoDb.Internal.Operations.Shared.DynamoDbHttpContent.CreatePooledContentReadStreamAsync()
at EfficientDynamoDb.Internal.HttpApi.SendAsync(DynamoDbContextConfig config, HttpContent httpContent, CancellationToken cancellationToken)
at EfficientDynamoDb.DynamoDbContext.PutItemAsync[TEntity](BuilderNode node, CancellationToken cancellationToken)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant