Databases Reference
In-Depth Information
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
The EntityDataSource control is used to retrieve the required entity instance from the
database. However, as you probably noticed, it does not specify the DefaultContainerName
and the EntitySetName properties normally required for the control to know which
ObjectContext to instantiate and which object set to query. This information is supplied
to the EntityDataSource by the DynamicDataManager , one of the new controls provided by
Dynamic Data.
The DynamicDataManager control has a DataControls collection that stores one or
more DataControlReference objects. In the Details page template, it stores a single refer-
ence to the FormView control. During the initialization phase of the page lifecycle, the
DynamicDataManager uses this reference to find the EntityDataSource control associated
with the FormView and configures it. In particular, it extracts the table name from the
current URL route and obtains the MetaTable object describing the table. The MetaTable
object provides the information necessary to initialize the EntityDataSource , including
the type of the ObjectContext as well as the name of the entity set to query.
Knowing the context type and the entity set is not enough to retrieve a specific entity
from the database. The query sent to the database server must also include a WHERE clause
that identifies the table row where it is stored. This task is performed by the
QueryExtender control, which is associated with the EntityDataSource . In the Details
page template, the QueryExtender uses a special type of data source expression, called
DynamicRouteExpression . At runtime, this object extracts the values of the primary key
columns from the URL and modifies the query generated by the EntityDataSource to
include appropriate filter criteria.
The FormView control defines an ItemTemplate to display the entity with the help of the
DynamicEntity control. As you remember, this control uses Dynamic Data entity templates
to generate either a generic, single column view of the entity or a custom view if a custom
template was defined for the entity. In the Details page template, the DynamicEntity
control does not specify the Mode property, so a read-only entity template is used.
In addition to the DynamicEntity , the ItemTemplate of the FormView control also includes
a set of links for users to edit or delete the entity or to go back to the List page. The Edit
and List actions are implemented by the DynamicHyperLink controls. When databound to
an entity instance, a DynamicHyperLink control generates a URL that points to another
dynamic page based on the value of the control's Action property. In this example, the
URL generated by the first DynamicHyperLink control looks like this:
http://localhost:49212/ Products/Edit. aspx? ProductID=1
In this URL, Products is the name of the MetaTable describing the current entity instance,
Edit is the name of the action specified in the Action property of the DynamicHyperLink
control, and ProductID=1 is the name and value of the primary key column of the current
 
Search WWH ::




Custom Search