Databases Reference
In-Depth Information
Scaffolding Support
Several properties of the
MetaModel
class are not related to metadata, but instead provide
support for dynamic scaffolding of the different template types used by Dynamic Data
applications:
public IFieldTemplateFactory FieldTemplateFactory { get; set; }
public EntityTemplateFactory EntityTemplateFactory { get; set; }
public FilterFactory FilterFactory { get; set; }
The
FieldTemplateFactory
property gets or sets an object responsible for creating field
templates. The
EntityTemplateFactory
is responsible for creating entity templates, and
the
FilterFactory
is responsible for filter templates. All three of these properties are
writeable, allowing you to replace the built-in factories when stock functionality is insuffi-
cient.
One particular example of when such a replacement would be beneficial is the limitation
of the built-in filter factory, which supports only Boolean, ForeignKey, and Enumeration
filters. However, this topic deserves a lot of attention and will be revisited in Chapter 13.
public string DynamicDataFolderVirtualPath { get; set; }
The
DynamicDataFolderVirtualPath
property determines where the template factories
look for templates. By default, this property is set to
“~/DynamicData”
but can be changed
to a different location if needed.
The main purpose of the
MetaTable
class is to help page templates generate user interface
for different entities in the data model. A single
MetaTable
instance describes an entire
entity class, including its type, properties, attributes, presentation, data access logic, and
security permissions.
Entity Definition
Each table in the model is identified by a name, which you can access using the
Name
property of the
MetaTable
class:
public string Name { get; }
Table name usually matches the name of the object context property you would normally
use to query the data. In the NorthwindEntities context class, you use the
Products
prop-
erty to retrieve instances of the Product entity class from the Products database table. The
MetaTable
instance describing the Product entity would have the name
Products
, the
same as the name of the
NorthwindEntities
property.