Databases Reference
In-Depth Information
custom properties and enable most of the rich template scaffolding for displaying and
filtering them. In this section, you see how this can be accomplished.
Model Providers
The provider API is defined in the System.Web.DynamicData.ModelProviders namespace.
At the high-level, it consists of the four classes shown in Figure 13.5— DataModelProvider ,
TableProvider , ColumnProvider , and AssociationProvider . The DataModelProvider class
provides the information required to construct a MetaModel object consumed by a
Dynamic Data application. For instance, it includes a property called Tables , which
returns a collection of TableProvider objects. Each TableProvider encapsulates a single
entity class and provides all information necessary to construct a MetaTable object. In
particular, it has a property called Columns that returns a collection of ColumnProvider
objects that MetaTable uses to construct MetaColumn instances. Unlike the metadata API,
where the MetaColumn class has two descendants, MetaForeignKeyColumn and
MetaChildrenColumn , that represent navigation properties (such as the Supplier property
of the Product entity), the provider API uses a separate class called AssociationProvider .
FIGURE 13.5 Metadata providers.
Dynamic Data comes with several built-in model providers, including providers for the
Entity Framework and LINQ to SQL. Each model provider includes a set of four classes,
each inheriting from the corresponding provider base class and overriding the required
virtual methods and properties. Knowledge of the built-in model providers is hard-coded
in the MetaModel class, which allows you to register both Entity Framework ObjectContext
types and LINQ to SQL DataContext types by calling the same RegisterContext method,
which takes Type as a parameter. However, the MetaModel class also defines an overloaded
version of the RegisterContext method that takes a DataModelProvider as a parameter
and that enables you to create custom providers for other LINQ-enabled frameworks and
use them with Dynamic Data.
 
Search WWH ::




Custom Search