Databases Reference
In-Depth Information
The MetaForeignKeyColumn Class
The MetaForeignKeyColumn class is a specialized descendant of the MetaColumn class that
represents many-to-one and one-to-one navigation properties, such as the Supplier prop-
erty of the Product entity in the Northwind data model. These “foreign key” columns in
the Dynamic Data metadata API have additional attributes that you can access through
this class.
public MetaTable ParentTable { get; }
The ParentTable property returns a MetaTable object describing the parent entity refer-
enced by the foreign key. In case of the Supplier property of the Product entity, the
ParentTable property returns the MetaTable object describing the Supplier entity. This
property serves an important role in implementing filtering and navigation functionality.
In particular, it is used by the ForeignKey field and filter templates to retrieve the rows
from the parent table for display in a drop-down list.
public ReadOnlyCollection<string> ForeignKeyNames { get; }
The ForeignKeyNames property of the MetaForeignKeyColumn class returns a collection of
the primitive entity properties that form the foreign key. For the Supplier property of the
Product entity, this property returns a collection with a single column name—SupplierID.
The collection returned by this property has multiple items only if the parent table has a
compound primary key and the foreign key includes multiple primitive properties.
Presentation Logic
The remaining properties and methods of the MetaForeignKeyColumn class provide support
for implementing presentation logic in Dynamic Data applications.
public bool IsPrimaryKeyInThisTable { get; }
The IsPrimaryKeyInThisTable property of the MetaForeignKeyColumn class returns true if
any of the primitive components of the foreign key is a member of the primary key of the
entity itself. For example, the Order_Detail entity in the Northwind data model has a
compound primary key that consists of OrderID and ProductID properties. The Order navi-
gation property is represented by a MetaForeignKeyColumn whose IsPrimaryKeyInThisTable
returns true because OrderID is a part of the primary key of the Order_Detail entity.
NOTE
Dynamic Data does not allow editing primary key values by default and uses the
IsPrimaryKeyInThisTableProperty property to display read-only field templates for
foreign key columns that are a part of a primary key in Edit mode.
public IList<object> GetForeignKeyValues(object row);
 
 
Search WWH ::




Custom Search