Databases Reference
In-Depth Information
Navigation Columns
So far, our discussion has been about the lookup rules Dynamic Data uses for columns of
primitive
types that can be stored using built-in system types like
Int32
and
String
. The
Dynamic Data metadata API represents them using the
MetaColumn
class.
Navigation
columns, on the other hand, are columns that provide access to one or more
entities that are defined as custom classes in the data model itself. There are three types of
navigation columns from the Dynamic Data prospective:
.
MetaForeignKeyColumn
represents a navigation property that returns a single entity
referenced by the underlying foreign key field. In the Northwind example, Product is
a foreign key column of the Order_Detail entity that represents the Product entity
referenced by the
ProductID
foreign key field.
.
MetaChildrenColumn
is an opposite of a foreign key. In the Northwind example,
Order_Details column of the Product entity returns all
Order_Detail
items that
reference a particular product instance.
.
Many-to-Many column is a special case of a
MetaChildrenColumn
where the
IsManyToMany
property is set to
true
. In the Northwind example, the Territories
column of the Employees entity returns all territories assigned to a particular
employee. Likewise, the Employees column of the Territory entity returns all
employees assigned to work in a particular Territory. Dynamic Data considers both
of these columns as Many-to-Many.
Navigation columns get special treatment during field template lookup. Unless the devel-
oper already placed a
UIHintAttribute
on a navigation property, Dynamic Data uses the
rules shown in Table 3.3 to come up with a default UI Hint.
TABLE 3.3
Navigation Column Rules
Column Type
UI Hint
MetaForeignKeyColumn
ForeignKey
MetaChildrenColumn
Children
MetaChildrenColumn, IsManyToMany = true
ManyToMany
In this example, it means that for the Product column of the Order_Details table, Dynamic
Data uses a template called
ForeignKey.ascx
; for the Order_Details column of the Product
table, it uses a template called
Children.ascx
; and for both Employee.Territories and
Territory.Employees columns, it uses the template called
ManyToMany.ascx
.
Effectively, there is no type fallback during template lookup for navigation columns.
However, Dynamic Data does perform mode fallback, so if your page needs a foreign key
template in Insert mode, it first tries
ForeignKey_Insert.ascx
, then
ForeignKey_Edit.ascx
,
and then
ForeignKey.ascx
if necessary. The default Dynamic Data project template