共用方式為


Entity.GetAttributeValue<T>(String) Method

Definition

Gets the value of the attribute.

public:
generic <typename T>
 virtual T GetAttributeValue(System::String ^ attributeLogicalName);
public virtual T GetAttributeValue<T> (string attributeLogicalName);
abstract member GetAttributeValue : string -> 'T
override this.GetAttributeValue : string -> 'T
Public Overridable Function GetAttributeValue(Of T) (attributeLogicalName As String) As T

Type Parameters

T

The type of the attribute.

Parameters

attributeLogicalName
String

The logical name of the attribute.

Returns

T

The value of the attribute.

Examples

GetAttributeValue<EntityReference>("regardingobjectid")

Remarks

When an entity instance does not include the attribute specified using the attributeLogicalName parameter this method will return the default value rather than throw an exception. An example default value returned for an EntityReference is a null, and for a DateTime a DateTime.MinValue is returned. You should not assume that the entity includes the attribute. It may not be included if the code that retrieved the attribute didn’t request it. You can use Entity.Contains(String) to check whether the entity instance includes the attribute.

Applies to