Databases Reference
In-Depth Information
The OnLoad method uses the Table property, provided by the EntityTemplateUserControl
base class, to access the MetaTable object describing the entity. Its GetScaffoldColumns
method returns a list of MetaColumn objects representing all “scaffolded” properties of the
entity class. Scaffolded properties are the properties that need their field controls gener-
ated automatically. This list includes
. Primitive properties of type String , Char , Byte , Int16 , Int32 , Int64 , Float , Double ,
Decimal , DateTime , TimeSpan , DateTimeOffset , Boolean , as well as enumerated types.
. Navigation properties that represent foreign keys and collections of child rows.
. Properties that have DisplayAttribute where AutoGenerateField property is set to
true .
. Properties that have ScaffoldColumnAttribute where Scaffold property is set to
true .
. Properties that have UIHintAttribute where UIHint property is not blank.
By default, the list of scaffolded columns excludes
. Automatically generated properties, such as identity columns used as primary keys.
. Primitive properties that support navigation properties, such as the CustomerID ,
which supports the Customer navigation property of the Order entity. Since the
navigation property will be scaffolded by default, there is no need to scaffold its
underlying primitive properties.
. Children navigation properties in insert mode. Child rows cannot be inserted before
their parent rows.
. Foreign key navigation properties if the current user has no read access to the parent
table (more on this in Chapter 14, “Implementing Security”).
The order of columns returned by the GetScaffoldColumns method matches the order in
which the properties appear in the entity class. You can change the order by applying the
DisplayAttribute to the entity properties and specifying its Order property. Listing 4.12
shows an example of doing that for the Supplier entity. Columns that do not have the
Order value specified explicitly appear after the columns that do, in the same order they
are declared in the entity class. The example in Listing 4.12 takes advantage of this fact by
specifying the Order values for the Phone and Fax columns so they appear immediately
after ContactName, ContactTitle, and CompanyName and before the address columns.
Another metadata property you commonly need to specify when relying on dynamic
entity templates is the display name of the column. This is necessary when the underlying
property name of a particular column does not match what you want your users to see on
the web pages of the application. For example, column names often contain multiple
words concatenated using underscores or Pascal naming convention, such as the
ContactName property of the Supplier entity. By setting the Name property of the
DisplayAttribute , you can specify the human-readable column name that will be
 
Search WWH ::




Custom Search