Databases Reference
In-Depth Information
helps your project stay agile, reduces waste, and enables you to focus on the most impor-
tant aspect of the information system—its domain model. After all, the biggest risk on any
development project is building the wrong thing. If your domain model is wrong, your
application will be wrong, no matter how pretty it looks. This is the most important
reason you might want to master the metadata-driven development of web applications
with Dynamic Data. This chapter focuses on how to do this effectively , points out some of
the pitfalls and shortcomings you might encounter, and discusses how to work around
them.
Basic Form Layout
When creating custom forms, you control their layout by explicitly creating table or
other HTML elements. You determine which entity properties appear on the form and
where they are displayed by creating a DynamicControl for each property and placing it in
the required location.
With the default entity template, Dynamic Data generates a single-column form for any
entity type, with labels on the left side and data entry fields on the right side. Unless you
specify otherwise, Dynamic Data uses a heuristic algorithm to display all appropriate
properties it supports. In particular, this list does not include the generated, custom, and
foreign key properties. Generated properties , such as properties mapped to identity columns
in a Microsoft SQL Server database, typically contain information not suitable for display
to end users. Custom properties , such as a FullName property that could be defined in a
contact entity class to concatenate the FirstName , LastName , and MiddleInitial proper-
ties, cannot be used in LINQ filters with Entity Framework and would break list pages.
Foreign key properties , such as a CustomerId , are not only inappropriate for users to see or
edit directly, they are a part of navigation properties, such as Customer , which are already
displayed, usually with a ForeignKey field template.
If this default set of properties selected for display by Dynamic Data does not meet your
requirements, you can explicitly show or hide a particular property with the help of the
DisplayAttribute . The code snippet next illustrates how to show the EmployeeID and
hide the Orders properties of the Employee entity:
[MetadataType(typeof(Metadata))]
partial class Employee
{
private abstract class Metadata
{
[Display(AutoGenerateField = true)]
public object EmployeeID { get; set; }
[Display(AutoGenerateField = false)]
public object Orders { get; set; }
}
}
 
 
Search WWH ::




Custom Search