EnumDataTypeAttribute Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Specifies that an entity member corresponds to an enumeration type.
Inheritance Hierarchy
System.Object
System.Attribute
System.ComponentModel.DataAnnotations.ValidationAttribute
System.ComponentModel.DataAnnotations.DataTypeAttribute
System.ComponentModel.DataAnnotations.EnumDataTypeAttribute
Namespace: System.ComponentModel.DataAnnotations
Assembly: System.ComponentModel.DataAnnotations (in System.ComponentModel.DataAnnotations.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Parameter, AllowMultiple := False)> _
Public NotInheritable Class EnumDataTypeAttribute _
Inherits DataTypeAttribute
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter, AllowMultiple = false)]
public sealed class EnumDataTypeAttribute : DataTypeAttribute
The EnumDataTypeAttribute type exposes the following members.
Constructors
Name | Description | |
---|---|---|
EnumDataTypeAttribute | Initializes a new instance of the EnumDataTypeAttribute class. |
Top
Properties
Name | Description | |
---|---|---|
CustomDataType | Gets a string that represents the name of the customized data type to associate with the member. (Inherited from DataTypeAttribute.) | |
DataType | Gets the type of the data object to associate with the member. (Inherited from DataTypeAttribute.) | |
DisplayFormat | Gets the object that represents the format of the data type. (Inherited from DataTypeAttribute.) | |
EnumType | Gets the enumeration type associated with the entity member. | |
ErrorMessage | Gets or sets the non-localizable error message to display when validation fails. (Inherited from ValidationAttribute.) | |
ErrorMessageResourceName | Gets or sets the property name on the resource type that provides the localizable error message. (Inherited from ValidationAttribute.) | |
ErrorMessageResourceType | Gets or sets the resource type that provides the localizable error message. (Inherited from ValidationAttribute.) | |
ErrorMessageString | Gets the localized or non-localized error message. (Inherited from ValidationAttribute.) |
Top
Methods
Name | Description | |
---|---|---|
Equals | Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
FormatErrorMessage | Applies formatting to the error message. (Inherited from ValidationAttribute.) | |
GetDataTypeName | Retrieves the name of the data type that is associated with the member. (Inherited from DataTypeAttribute.) | |
GetHashCode | Returns the hash code for this instance. (Inherited from Attribute.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetValidationResult | Determines whether the specified object is valid and returns an object that includes the results of the validation check. (Inherited from ValidationAttribute.) | |
IsValid | Determines whether the specified object is valid. (Inherited from ValidationAttribute.) | |
Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Validate | Determines whether the specified object is valid and throws a ValidationException if the object is not valid. (Inherited from ValidationAttribute.) |
Top
Remarks
You apply the EnumDataTypeAttribute attribute to a property when the property represents an enumeration type that is not available in the data source. For example, you may store a value as an integer in your database, but you want to associate that integer to an enumeration value in your application. When you apply the EnumDataTypeAttribute attribute to a property, you provide the type of the enumeration you want to associate with the property.
If the value of the property is nulla null reference (Nothing in Visual Basic) or an empty string (""), the value will not fail validation for the EnumDataTypeAttribute attribute. To validate that the value is not nulla null reference (Nothing in Visual Basic) or an empty string, use the RequiredAttribute attribute.
Version Information
Silverlight
Supported in: 5, 4, 3
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also