Databases Reference
In-Depth Information
The DefaultValue property of the MetaColumn class returns a value used by default for the
entity property in Insert mode. It can be specified in code by applying the
DefaultValueAttribute to the entity property in code.
NOTE
Dynamic Data, or more specifically the EntityDataSource, does not create a new entity
instance when generating an insert page. This is significant, because even though the
Entity Framework designer allows you to define default property values in the model,
the stock code generators produce entity classes where the default values are
assigned in code and entity properties do not have the DefaultValueAttribute .
This results in inconsistent behavior when an entity instance is created in code as
opposed to the Dynamic Data UI. Although it is straightforward to apply the
DefaultValueAttribute manually, doing so would be prone to errors in large data
models. Instead, consider switching to T4-based text templates for generating entity
classes and modifying them to automatically generate the DefaultValueAttribute .
public bool IsRequired { get; }
The IsRequired property of the MetaColumn returns true if the entity property must have a
value. By default, this property returns True for non-nullable entity properties. You can
also set it by applying the RequiredAttribute to the entity property in code.
Display Support
Several properties of the MetaColumn define textual labels describing the entity property
that are or can be displayed to the end users.
public virtual string DisplayName { get; }
The DisplayName property returns a string that serves as a label for the entity property on
dynamically generated single-item pages, such as Insert, Edit, and Details.
public virtual string ShortDisplayName { get; }
The ShortDisplayName returns a string used in a header of a grid column that displays the
entity property values on a dynamically generated List page.
public virtual string Prompt { get; }
The Prompt property returns a string that could be used as a watermark in Edit and Insert
mode field templates. None of the field templates supplied with Dynamic Data project
templates take advantage of this property. However, you could easily implement support
for it with the TextBoxWatermarkExtender from the AJAX control toolkit.
All three of these properties— DisplayName , ShortDisplayName , and Prompt —can be speci-
fied in code by applying the DisplayAttribute to the entity property.
public virtual string Description { get; }
 
Search WWH ::




Custom Search