-
This code obviously doesn't work because meta.Target.Property doesn't contain a method GetCustomAttributes like propertyinfo does. But is there a way to get those attributes? If the attribute exists, I'd like to use the LogicalName value as below. Otherwise, proceed with a standard setter. SetAttributeValue is also a method on the class (Xrm.Entity). Additionally, could I extend my TypeAspect attribute with a LogicalName property that would also decorate the target property with [AttributeLogicalName(LogicalName)]? Then I would know it always exists, and could grab the value easier in my OverridePropertySetter.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
To reflect attributes, you can use the Attributes collection on To add an attribute:
You may consider passing a parameter from |
Beta Was this translation helpful? Give feedback.
-
@bradlee-s This is the same problem I have encountered, I have fixed it and it should be included in the next release. |
Beta Was this translation helpful? Give feedback.
To reflect attributes, you can use the Attributes collection on
meta.Target.Property
.To add an attribute:
BuildAspect
.builder.Advice.AddAttribute
. However the attribute added inBuildAspect
will not be visible in your template method (for the sake of consistency and ease of programming, we consistently expose, to any aspect A, the code model in the state before that aspect A was applied.You may consider passing a parameter from
BuildAspect
to your template.