Generic FAQ on DADO Solution®
- Why do I need to get a clone before editing an object ?
- Which cache configuration should I use ?
- What is an "entity type" and what is the difference to a "non-entity" type ?
- What is a "dependent type" ?
- What is updated when I save an object in a "Context" or "UnitOfWork" ?
- Should I inherit my objects from some base objects ?
- Is DADO Solution® really thread safe and scalable ?
- Is it possible to embed the mapping configuration file with the application ?
1. Why do I need to get a clone before editing an object ?
In DADO Solution® all objects are by default read-only, that means when referenced they cannot be modified directly, but you need to retrieve (through the API 'Context.GetEditableObject(...)') an editable clone of it.
This allows to register the status of an object to check for modifications or for optimistic concurrency. When getting an editable copy of an object you can modify all its attributes (literal properties, like Strings, Integers, Guids, Byte arrays, etc.) and referenced composite members (like the positions of an invoice).
1.a Why objects are not registered automatically when queried ?
RE: The registration process is very fast, but on a large amount of objects (like the ones returned by a query) this may take some time, and since in most use cases you only query data and the update process in anyway delayed by the user interaction times, we decided to avoid any automatism in the object registration process.
2. Which cache configuration should I use ?
Depends on the type extent and on the expectations you have on the client side. If you have a small extent of a defined type (usually the case with configuration codes) we recommend to use a full-cache; in all other cases, if your client code can accept clones, avoid any cache, otherwise use a hard- cache.
3. What is an "entity type" and what is the difference to a "non-entity" type ?
Entity types are types which represent an atomic persistable unit of data and can be queried as standalone objects. Entity types must be classes (value types are not supported as entity types). In a CRM application this could be a "Customer", "Employee" and "Supplier" type. Entity types supports an own adapter (entity adapter), validation and caching. Non-entity types are primitive data types (ES: Integer, String, etc) and objects which don't represent a standalone unit of data, for example a byte or string array, an image, a Guid or a collection used for a relationship. All entity types of your model must be configured (via code or with tools like DADO Database Mapper® or DADO Xml Mapper®), while an acceptable descriptor is automatically generated by DADO Solution® at runtime for non-entity types.
4. What is a "dependent type" ?
Dependent types are special entity types which can be queried but cannot be created/updated/deleted as standalone objects (an "InvalidOperationException" is thrown). "Dependent types" are always objects related through a 1:1 or 1:n relationship to another entity object (owner) and enhance its information content. Common examples of dependent types could the the entries of an invoice (you don't create and validate a new entry alone, but you add/remove an entry to an invoice), the chapters of a book (you can add/remove a chapter from a book, but you cannot just create a standalone chapter), etc.. DADO Solution® automatically handles the creation/update and deletion of dependent types when creating/updating and deleting the owner of them.
5. What is updated when I save an object in a "Context" or "UnitOfWork" ?
When you save an object the object itself is persisted and all direct referenced unsaved not dependent objects are created/updated/deleted and referenced non-dependent types are only saved in not saved yet, but are not checked for changes, and so not updated.
||Referenced non-composite types
||Referenced composite types|
|Save of a new object
||Only saved if new (unsaved)
||Inserted/updated depending of the status|
|Update of an existing object
||Only saved if new (unsaved)
||Inserted/updated/deleted depending of current and initial status|
|Delete of an object
||Never deleted. Eventual references are deleted
6. Should I inherit my objects from some base objects ?
Absolutely not ! DADO Solution® was designed from the beginning to be absolutely not intrusive, so just inherit from System.Object or your own base classes. DADO Solution® provides anyway in the namespace "DADO.Persistency.BaseTypes" some base utility classes you can inherit from and which provide base properties and business functionalities common to many business object models.
Here a short description of them (for more details look the Developer documentation)
Provides the base class for many business objects with properties and overridable members like ID, DateTimeStamp, Validate(), Save(), Delete(), etc.
Inherits from DataObject and provides properties and methods common to code (or reference) objects, like a code (string), a text (string array for multi-language applications), basic validation rules (code and text mandatory), etc.
Inherits from DataObject and provides properties and methods common to filters. Filters are objects to persist a criteria definition
7. Is DADO Solution® really thread safe and scalable ?
DADO Solution® was designed from the beginning to work on the server side in an application server (DADO Application Server® or any other application server like Microsoft IIS) and to be accessed concurrently by more clients; for this reason all released versions of DADO Solution® are granted to be full multi-threading safe. When accessing your business objects for a refresh DADO Solution® executes a synchronization lock on the object itself.
8. Is it possible to embed the mapping configuration file with the application
Yes. The configuration file for a defined context (created with DADO Database Mapper®, DADO Xml Mapper® or DADO Broker System®) can be loaded from a file, an embedded resource, a stream or any network location.