-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: support [Column] #85
feat: support [Column] #85
Conversation
# Conflicts: # src/Dapper.AOT.Analyzers/Internal/Inspection.cs
/// <summary> | ||
/// Specifies whether to use [System.ComponentModel.DataAnnotations.Schema.ColumnAttribute] for additional behavioral configuration | ||
/// </summary> | ||
public class UseColumnAttributeAttribute : Attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the allowed usage here? can it be applied at the module level, or is it only respected when attached to the same type? are more than one allowed? can we add [AttributeUsage(...)]
here accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added such an expression.
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
let me know if such AttributeUsage
is correct
looking good; fixed some minor nits:
an open question on the new attribute, but: looking good! |
…om/DeagleGross/DapperAOT into dmkorolev/support-column-attribute
Thanks for the useful advices and fixes, Marc! Sorry for attribute usage - I added it. Ready for review |
Goal:
Support
[System.ComponentModel.DataAnnotations.Schema.ColumnAttribute]
as an additional way to override parameter name.Requested by some users (stackoverflow)
Example:
To make override work, one need to specify both
[Column]
and[UseColumnAttribute]
attributes, for example:Rules:
[Column]
and either[UseColumnAttribute]
or[UseColumnAttribute(true)]
is defined, than override will work[UseColumnAttribute(false)]
is explicitly specified, then overriding will not happen[Column]
is specified, but[UseColumnAttribute]
is missing, then DAP043 will be emitted to the user: "Attach the [UseColumnAttribute] attribute to make Dapper consider [Column]"[DbValue]
with propertyName
is specified, then a warning message will be emitted to the user: DAP042 "A column name is specified via both [DbValue] and [Column]; '<dbvalue_name>' will be used"Closes #36