domain class is - first and foremost - a set of typed properties. These properties require annotations, as explained on this related page: domain object class.
Location includes string properties
String properties should be attributed to give dbschema.exe important clues on how these properties should be constrained in the database. After all,
domain objects can be persisted. What's more BOC controls also enforce those constraints.
As you might guess,
[ StringProperty ]'s property
MaximumLength specifies the maximum string length. The
Street's maximum length is not only generated into the database script (see dbschema.exe), it is also inforced by re-form, or, the particular BOC control receiving a
Street value in an edit form. The BOC control will not let the user input a string longer than 60 characters.
re-motion derives the characteristics of nullability directly from the .NET types.
string-s are nullable, but what if don't want that for our application? An address without a
Street name is not any good, that's why we override the
string type's nullability with the property
Nullable=false in the
[ StringProperty ] attribute.
Country? clearly is nullable, so a country enum is not mandatory, neither in the database nor in edit forms.
int - the type of the
ZipCode property - is mandatory, and that's how it is mapped to both the database schema and the user interface.
[ DBColumn ] attribute renames the property for the database. If not told otherwise, re-store takes the name of the property as name for the column in the database. The table itself is named after the class.
Location class this means that the
Location table will contain these columns:
- there won't be a
Number column, because we renamed it; the column will be named
Note that all properties here are
virtual. This is not an accident, this is a requirement, as explained here:
[ MultiLingualResources ] attribute is discussed in a later section, when we cover globalization: FIXME.