Jaa


MetadataTypeAttribute Class

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

Specifies the metadata class to associate with a data model class.

Namespace: Microsoft.Practices.EnterpriseLibrary.Validation.DataAnnotations
Assembly: Microsoft.Practices.EnterpriseLibrary.Validation.Silverlight (in Microsoft.Practices.EnterpriseLibrary.Validation.Silverlight.dll) Version: 5.0.505.0

Syntax

public sealed class MetadataTypeAttribute : Attribute
'Declaration
Public NotInheritable Class MetadataTypeAttribute _
    Inherits Attribute
public ref class MetadataTypeAttribute sealed : public Attribute

Remarks

This attribute might be deprecated in the future in favor of a Silverlight built-in System.ComponentModel.DataAnnotations.MetatadataTypeAttribute. The current implementation allows a Silverlight application using Validation Application Block to take advantage of this feature which is available in the .NET Framework, and it can be useful for cross-tier validation scenarios.

The MetadataTypeAttribute attribute enables you to associate a class with a data-model partial class. In this associated class you provide additional metadata information that is not in the data model. For example, in the associated class you can apply the RequiredAttribute attribute to a data field. This enforces that a value is provided for the field even if this constraint is not required by the database schema.

You use the MetadataTypeAttribute attribute as follows: - In your application, create a file in which you create the data-model partial class that you want to modify. - Create the associated metadata class. - Apply the MetadataTypeAttribute attribute to the partial entity class, specifying the associated class.

When you apply this attribute, you must adhere to the following usage constraints: - The attribute can only be applied to a class. - The attribute cannot be inherited by derived classes. - The attribute can be applied only one time.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.Practices.EnterpriseLibrary.Validation.DataAnnotations.MetadataTypeAttribute

See Also

MetadataTypeAttribute Members

Microsoft.Practices.EnterpriseLibrary.Validation.DataAnnotations Namespace