1.2. Understanding Model Metadata

The heart of Dynamic Data is the metadata defined in the model. There are many attributes available to apply to the model to change how a data field is rendered to the user. The following highlights some of the more common attributes used. Note that the attributes are found in the System.ComponentModel and System.ComponentModel.DataAnnotations namespaces.

using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;

[MetadataType(typeof(ContactMetadata))]
[DisplayColumn("LastName", "LastName")] public partial class Contact { } public class ContactMetadata { [DisplayName("Email Address")] [Required] [RegularExpression(@"^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$", ErrorMessage ...

Get Secrets of Real World ASP.NET Dynamic Data Web Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.