Language preference:

Phase 2 / More DataAnnotations

Business logic is full of special cases. You will likely create new Attributes and code your user interface to respect their rules. However, only do so after reviewing these DataAnnotation Attributes. Those without the "DESDA." prefix are found in the System.ComponentModel.DataAnnotations namespace.

  • DisplayFormatAttribute – Assists the Field Template when it formats a value as a string. Provides these properties: NullDisplayText (used when a DataField value is null and needs to be displayed in a label), DataFormatString (applied with String.Format to the value), ConvertEmptyStringToNull (used when saving a blank entry), and ApplyFormatInEditMode.
  • CategoryAttribute – Helps group DataFields for various features of the user interface. BLD's NamedStyles feature can change the style sheet class based on a Categories, and by the Automatic Scaffolding can to build lists of DataFields based on a group.
  • DESDA.SortableColumnAttribute – Determines if the DataField is sortable or not.
  • EditableAttribute – Offers one way to restrict users from editing specific DataFields. If you have role-based security, use the DESDA.ColumnRestrictionAttribute instead of the EditableAttribute.
  • DESDA.UIHintAttribute – Very user interface specific and therefore should be used with great care. It overrides the default Field Template so you can use different user interfaces for a specific datatype. The same capability is available in BLD's user interface controls, making this probably unnecessary.
  • DESDA.CacheListAttribute – Used on Enumerated and ForeignKey DataFields to retain their lists in the Application Cache instead of recalling their elements from the database with each page request.
  • DESDA.AttributeSourceAttribute – Shares Attributes between properties. Makes setting up Entity classes for Views easier and less errorprone by ensuring each property in the View’s Entity has the same business logic as the Entity from which is was formed.

In the next topic, you will use the BLD Database Explorer with changes applied based on the topics of Phase 2.