Skip to content

Conversation

alamb3142
Copy link

This catches any writeable property, including internal properties that were previously ignored.

This caught me out because my I created my table models as internal models (which I think is the default now if you're working in VS 2022?) to prevent dependant projects from trying to use them, and only after debugging Dapper.Contrib locally did I realise that only the public properties were being mapped to column names.

For reference here's the error message I was seeing when calling InsertAsync on my internal model:
image

And the SQL it generated to cause this was:
INSERT INTO dbo.my_table () values (); SELECT SCOPE_IDENTITY() id

This catches any writeable property, including internal properties that were previously ignored
@alamb3142
Copy link
Author

Please let me know if there's a reason why public properties only are better. I'd also be happy to add in a check here that throws when 0 properties are found and some tests around this behaviour

Binding flags filter still pulls back private properties, this prevents those properties from being mapped
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.

1 participant