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