The base class
BindableDomainObject, in this case) have generic protected static methods for creating and retrieving domain object instances for a given class.
DomainObject.GetObject<T>fetches an object from the database
DomainObject.NewObject<T>creates a new object
Since these methods are protected, you can't use them from application code. If you want to use static
NewObject you must override public specializations for your objects.
This is what we do here. Each class gets its static
GetObject (not generic). The
Location class, for example:
- both methods, like all work with domain objects, requires the context of transaction
- even read-only operations require a transaction
NewObjectdoes NOT store a (hollow, uninitialized) domain object in the database
- all changes to domain objects are persisted with
Commit()for the transaction providing the context
We will take a closer look at transactions in section FIXME.