Databases Reference
In-Depth Information
table in the Northwind database, it can be changed by applying the DisplayNameAttribute
to the entity class as shown here:
using System.ComponentModel;
[DisplayName(“Order Items”)]
partial class Order_Detail { }
Last, the MetaTable class has a set of three properties that determine how the actual data
retrieved from the database table needs to be displayed by the user interface elements
generated by Dynamic Data:
public virtual MetaColumn DisplayColumn { get; }
public virtual MetaColumn SortColumn { get;
public virtual bool SortDescending { get; }
The DisplayColumn property returns a MetaColumn object that represents the property
whose value would allow a user to identify a particular entity instance or table row. For
the Supplier entity class in the Northwind database scenario, this would normally be the
CompanyName property; for the Product entity class, it would be the ProductName . The read-
only ForeignKey field template uses the DisplayColumn to provide text for a hyperlink it
generates, so that contact name of a Supplier is displayed on the Product details page.
The SortColumn property returns a MetaColumn that should be used to sort the items
retrieved from the database by default, and the SortDescending property indicates
whether the rows should be sorted in ascending or descending order of the SortColumn
values. The ForeignKey_Edit field template uses these properties to sort the items in the
drop-down list it generates, making the Suppliers appear in the order of their
CompanyName:
using System.ComponentModel.DataAnnotations;
[DisplayColumn(“CompanyName”, “CompanyName”, false)]
partial class Supplier { }
By default, MetaTable uses a heuristic algorithm to guess the right display column. All
three of these properties, DisplayColumn , SortColumn , and SortDescending , can also be
specified explicitly by applying the DisplayColumnAttribute to the entity class as just
shown. Its constructor takes the name of the display column, the name of the sort
column, and a Boolean value that indicates whether default sorting should be performed
in descending order.
Search WWH ::




Custom Search