Databases Reference
In-Depth Information
}
return new AttributeCollection(attributes.ToArray());
}
}
}
Notice that the overridden getter first calls the inherited Attributes property to obtain
the initial list of attributes. This includes all default attributes already discovered by the
column provider, which in the case of UnleashedColumnProvider includes the attributes
returned by the PropertyDescriptor object that represents the custom entity property. If
the list of attributes includes a CustomPropertyAttribute , the getter parses the names of the
foreign key and the display fields from its Expression value and adds a UIHintAttribute
and a FilterUIHintAttribute to the list. In the end, the combined list of attributes is
used to create a new AttributeCollection object, which the getter returns.
Even when generating attributes, such as the UIHintAttribute and FilterUIHintAttribute
in this example, it is important to still allow specifying these attribute explicitly. One one
hand, you might need to specify more information than can be inferred programmati-
cally. But more importantly, imagine trying to troubleshoot a problem caused by the
model provider silently replacing the attributes you applied in code when the application
runs. If you are careful, however, the automatic generation of attributes fits well in the
convention-based development experience offered by Dynamic Data—out of the box, it
just works, but you can change it if you want.
Summary
The approach to developing metadata-driven list pages is similar to building dynamic
forms. You want to provide enough information in the entity model to generate a reason-
ably good UI dynamically, eliminating or postponing the need to create and maintain
custom pages. You do that by specifying data annotation attributes, such as the
FilterUIHintAttribute , for entity classes and their properties in the entity model. With
the additional metadata information, you can take advantage of the built-in capabilities of
Dynamic Data controls or extend the framework to eliminate its shortcomings.
One of the biggest shortcomings in the built-in support for filter templates in Dynamic
Data is the simplistic algorithm used to look up filter templates. Unlike the sophisticated
algorithm used for field templates, the filter template algorithm assumes the existence of
only three filter templates that come with Dynamic Data out of the box. By replacing the
built-in FilterFactory with the UnleashedFilterFactory , you can bring the filter lookup
functionality up to the same level with field templates and eliminate the need to specify
the FilterUIHintAttribute for every filterable property in the entity model.
 
 
Search WWH ::




Custom Search