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

Support [Column] #36

Closed
mgravell opened this issue Sep 9, 2023 · 1 comment · Fixed by #85
Closed

Support [Column] #36

mgravell opened this issue Sep 9, 2023 · 1 comment · Fixed by #85
Assignees

Comments

@mgravell
Copy link
Member

mgravell commented Sep 9, 2023

Currently we support names (parameter and column) via [DbValue], however there is also a well-known [System.ComponentModel.DataAnnotations.Schema.ColumnAttribute] that is commonly used.

I'm hesitant to use this blindly, because that would change existing behavior, so this should be triggered via a new UseColumnAttributeAttribute (yes, the naming is weird - see also XmlAttributeAttribute) which would apply at all levels (like most DapperAOT attributes):

  • feature should only apply if [UseColumnAttribute] or [UseColumnAttribute(true)] is in play
  • [UseColumnAttribute(false)] explicitly disables
  • only Name would be used; we aren't interested in Order etc
  • if we see a [Column(...)] with a Name but don't see any explicit on/off flag, emit a warning so the user knows to opt in/out
  • works similar to [DbValue] with Name, but: doesn't impact parameters

See also https://stackoverflow.com/questions/77073286/can-dapper-mappings-be-automated-with-attributes

@mgravell
Copy link
Member Author

mgravell commented Sep 13, 2023

See ElementMember.DbName; IMO to avoid confusion, if there is both an enabled [Column(...)] and a [DbValue(...)] providing a different name (we can ignore if they match), we should issue a warning but take the DbValue(...) version, i.e.

A column name is specified via both [DbValue] and [Column]; "Whatever" will be used

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 a pull request may close this issue.

2 participants