문제

  1. Hello, can you please explain me what is the significance of [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("activityid")] in the following code?

    [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("activityid")]
    public Microsoft.Xrm.Sdk.EntityReference ActivityId
    {
        get
        {
            return this.GetAttributeValue<Microsoft.Xrm.Sdk.EntityReference>("activityid");
        }
        set
        {
            this.OnPropertyChanging("ActivityId");
            this.SetAttributeValue("activityid", value);
            this.OnPropertyChanged("ActivityId");
        }
    }
    

    I searched for this thing and I got many posts which gave me answer as the ones in square brackets are Attributes in C#. But, then attributes are related with methods. Over here, ActivityId doesn't seem to be a method. So, how can [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("activityid")] act as an attribute?

  2. Is it related to C# or it has got something to do with CRM?

도움이 되었습니까?

해결책

The confusion comes from your statement about attributes only being valid on methods. Attributes can be valid on items specified in the AttributeTargets enum:

http://msdn.microsoft.com/en-us/library/system.attributetargets.aspx

This then puts you back to the answer being "they are attributes". That attribute has simply been applied to a property.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top