Databases Reference
In-Depth Information
When a user clicks one of the dynamic hyperlinks, page templates typically have to
extract column values from the request query string. This is done with the help of the
GetColumnValuesFromRoute
method, which is used by the list page template and the
GetDataKeyFromRoute
method, which does the same thing for single-item templates.
public virtual string GetDisplayString(object row);
When a human-readable string representing a row or an entity is needed, you can use the
GetDisplayString
method. This is how the ForeignKey field and filter templates set the
Text
property of the
ListItem
objects for their
DropDownList
controls. This method takes
into account the
DisplayColumn
of the
MetaTable
to locate the column whose value will
serve as the display string.
public string GetPrimaryKeyString(IList<object> primaryKeyValues);
public string GetPrimaryKeyString(object row);
If you need a string that can be used to uniquely identify an entity and enable retrieving
it from database later, you can use one of the
GetPrimaryKeyString
overloads. This is how
the ForeignKey field and filter templates generate the
Value
property of the
ListItem
objects in their
DropDownList
controls.
Security Support
Last, but not least, the
MetaTable
class includes a set of virtual methods that can be used
to implement table-level authorization. The default implementation of these methods
returns
true
, making all tables accessible for all users, as long as these tables are scaf-
folded. Chapter 14 discusses how Dynamic Data applications can take advantage of this
extensibility mechanism to implement role-based UI trimming:
public virtual bool CanDelete(IPrincipal principal);
public virtual bool CanInsert(IPrincipal principal);
public virtual bool CanRead(IPrincipal principal);
public virtual bool CanUpdate(IPrincipal principal);
The
MetaColumn
class describes a single property of an entity class. In the Northwind data
model, where the Product entity class represents the Products database table, Dynamic
Data creates a separate instance of the
MetaColumn
class for each property the
Product
entity class defines, including primitive properties, like
ProductID
,
ProductName
,
CategoryID
, and
SupplierID
as well as navigation properties like Category and Supplier.
The navigation properties of entity classes are represented by the
MetaForeignKeyColumn
and
MetaChildrenColumn
classes derived from the
MetaColumn
class. These classes are
discussed later in this chapter; this section focuses on the common properties of all meta
columns and their specialized descendants.