Language preference:

Phase 1 / Descriptor classes: The structure and business rules of your database

BLD learns about the structure of your database when you register your DataContext class with it. From there, it parses the DataContext and Entity classes, extracting numerous details, such as table name, property type, and all of your business rules. The Descriptor classes handle the parsing, and are preserved globally so any code can use these details.

You will be interacting with these classes, so it helps to understand them.

  • DataContextDescriptor – Describes a DataContext class. In addition to keeping a list describing its Entity classes, it provides access to the RestrictionManager (for restrictions to tables and columns by user role). It also has a number of event handlers to let you override how many types of objects are created.
  • EntityDescriptor – Describes an Entity class. An Entity class can supply business rules, such as the table’s display name and security restrictions. EntityDescriptor can also validate an Entity.
  • DataFieldDescriptor – Describes a DataField (property on the Entity class). There are an enormous number of properties on it to describe both the structure of the DataField (like IsPrimaryKey, IsString, and DataFieldPropertyType) and your business rules attached to it. They know how to validate, get, and set a data value.
  • RelationshipDataFieldDescriptor – Some DataFields describe relationships and are not actually columns in the table. These DataFields are described with this specialized DataFieldDescriptor class.

Here are some typical cases when they are used.

  • You must instantiate a DataContextDescriptor for each unique DataContext class and register it. This usually happens in the application startup code. This is shown in the next topic.
  • When using BLD DataAccessObjects, your custom Insert and Update methods may need to know details about individual columns to be written out. The EntityDAO class exposes the EntityDescriptor class in its EntityDescriptor property. Call its GetDataFieldDescriptor() method, passing the name of the DataField. With the resulting DataFieldDescriptor, you now know everything about the DataField including database specific concepts like column name and DbType.
  • You customize business rules at runtime through the ICustomizeDataField interface. It’s CustomizeDataField() method is passed an ActiveDataField object. This class is a wrapper around the global DataFieldDescriptor, which you are never allowed to modify. Instead, you provide your edits to the ActiveDataField, often accessing the DataFieldDescriptor through its GlobalDataFieldDescriptor property to learn the global business rules.
  • In the UI, Field Templates are required to follow your business rules. They have a reference to the DataFieldDescriptor in the DataFieldDescriptor property. They also have an ActiveDataField object with the modifications to the DataFieldDescriptor.
  • Filter Templates also use DataFieldDescriptors to follow your business rules.
  • When you use a different Data Access Layer technology for your DataContext and Entity classes, you will create new Descriptor classes to parse those objects.

BLD includes a web form called the Descriptors Class Browser to let you explore the Descriptors in your application.

Show the Descriptor Browser

At this point, you have enough for BLD's user interface features to use. In the next topic, you will connect BLD to your business logic.