MaxLengthAttribute Class

Specifies the maximum length of array or string data allowed in a property.

Inheritance Hierarchy

System.Object
  System.Attribute
    System.ComponentModel.DataAnnotations.ValidationAttribute
      System.ComponentModel.DataAnnotations.MaxLengthAttribute

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  EntityFramework (in EntityFramework.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Parameter, AllowMultiple := False)> _
Public Class MaxLengthAttribute _
    Inherits ValidationAttribute
'Usage
Dim instance As MaxLengthAttribute
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter, AllowMultiple = false)]
public class MaxLengthAttribute : ValidationAttribute
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Parameter, AllowMultiple = false)]
public ref class MaxLengthAttribute : public ValidationAttribute
[<AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Parameter, AllowMultiple = false)>]
type MaxLengthAttribute =  
    class
        inherit ValidationAttribute
    end
public class MaxLengthAttribute extends ValidationAttribute

The MaxLengthAttribute type exposes the following members.

Constructors

  Name Description
Public method MaxLengthAttribute() Initializes a new instance of the MaxLengthAttribute class. The maximum allowable length supported by the database will be used.
Public method MaxLengthAttribute(Int32) Initializes a new instance of the MaxLengthAttribute class.

Top

Properties

  Name Description
Public property ErrorMessage (Inherited from ValidationAttribute.)
Public property ErrorMessageResourceName (Inherited from ValidationAttribute.)
Public property ErrorMessageResourceType (Inherited from ValidationAttribute.)
Protected property ErrorMessageString (Inherited from ValidationAttribute.)
Public property Length Gets the maximum allowable length of the array/string data.
Public property RequiresValidationContext (Inherited from ValidationAttribute.)
Public property TypeId (Inherited from Attribute.)

Top

Methods

  Name Description
Public method Equals (Inherited from Attribute.)
Protected method Finalize (Inherited from Object.)
Public method FormatErrorMessage Applies formatting to a specified error message. (Overrides <see cref="M:System.ComponentModel.DataAnnotations.ValidationAttribute.FormatErrorMessage(System.String)" />) (Overrides ValidationAttribute.FormatErrorMessage(String).)
Public method GetHashCode (Inherited from Attribute.)
Public method GetType (Inherited from Object.)
Public method GetValidationResult (Inherited from ValidationAttribute.)
Public method IsDefaultAttribute (Inherited from Attribute.)
Public method IsValid(Object) Determines whether a specified object is valid. (Overrides <see cref="M:System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(System.Object)" />) (Overrides ValidationAttribute.IsValid(Object).)
Protected method IsValid(Object, ValidationContext) (Inherited from ValidationAttribute.)
Public method Match (Inherited from Attribute.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)
Public method Validate(Object, String) (Inherited from ValidationAttribute.)
Public method Validate(Object, ValidationContext) (Inherited from ValidationAttribute.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method _Attribute.GetIDsOfNames (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfo (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfoCount (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.Invoke (Inherited from Attribute.)

Top

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

Reference

System.ComponentModel.DataAnnotations Namespace

Other Resources

Entity Framework 4.1

Data Developer Center