The Entity (DTO) is primarily responsible for defining the domain-based model (and contract where accessible externally over-the-wire). They are also used to define the reference data model.
The aim here is decouple this definition, where applicable, from the underlying data source. This is likely to be defined differently, with an alternate naming convention, alternate shape/structure, etc. This also enables the data source to evolve independently of this model, as well as possibly hide additional implementaion details.
Beef looks to define two versions of the entity, the Common
(external) and Business
(internal) representations. This allows additional features to be leveraged internally that need not be exposed externally.
The key Beef entity capabilities are enabled primarily by the CoreEx.Entities
and CoreEx.Entities.Extended
namespaces.
A code-generated Business
(internal) entity will get the following capabilities:
- Inherit from CoreEx.Entities.Extended.EntityBase or CoreEx.RefData.Extended.ReferenceDataBaseEx
- Support for System.ComponentModel.INotifyPropertyChanged.
- Support for System.ComponentModel.IChangeTracking.
- Support for CoreEx.Entities.IReadOnly.
- Support for CoreEx.Entities.ICopyFrom.
- Support for CoreEx.Entities.ICleanUp.
- Support for CoreEx.Entities.IInitial.
- Support for Clone extension method.
- Collection inheriting from CoreEx.Entities.Extended.EntityBaseCollection or CoreEx.RefData.ReferenceDataCollectionBase
- Collection result inheriting from CoreEx.Entities.CollectionResult.
Additional interfaces are automatically implemented where corresponding properties, etc. are specified:
- Support for CoreEx.Entities.IIdentifier or CoreEx.Entities.IPrimaryKey (composite).
- Support for CoreEx.Entities.IETag.
- Support for CoreEx.Entities.Extended.IChangeLogEx.
- Support for CoreEx.Entities.IPartitionKey.
The sample PerformanceReview
entity demonstrates the richness of the generated output.
A code-generated Common
(external) entity will get the following interfaces automatically implemented where corresponding properties, etc. are specified:
- Support for CoreEx.Entities.IIdentifier or CoreEx.Entities.IPrimaryKey (composite).
- Support for CoreEx.Entities.IETag.
- Support for CoreEx.Entities.IChangeLog.
- Support for CoreEx.Entities.IPartitionKey.
The sample PerformanceReview
entity demonstrates the simpler alternative of the generated output.
The Entity
and its corresponding Property
elements within the entity.beef-5.yaml
configuration primarily drives the output. There is a generated class per Entity
with the same name.