Skip to content

Conversation

@alatanza
Copy link
Contributor

This PR resolves an issue where assigning unboxed value types to dynamic properties in DapperRow objects caused an exception. The problem occurred because value types are not automatically boxed when using expression trees, resulting in errors like:

System.ArgumentException: Expression of type 'System.Int32' cannot be used for parameter of type 'System.Object' of method 'System.Object SetValue(System.String, System.Object)'

The fix ensures that value types are properly boxed before being assigned.

Tests have been added to validate the behavior, covering scenarios with reference types, boxed value types, and unboxed value types.

Please review and provide any feedback or suggestions. Thanks for your time and consideration!

Copy link
Member

@mgravell mgravell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@mgravell mgravell merged commit a3804ce into DapperLib:main Oct 13, 2024
2 checks passed
@alatanza alatanza deleted the set-dynamic-property-value-type branch October 13, 2024 08:40
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

Successfully merging this pull request may close these issues.

2 participants