FAQ's FAQ on DADO Database Mapper®   /   


FAQ on DADO Database Mapper®

  1. How should I design my object model and what should I know ?
  2. Why are two different processes to configure the serialization and to map the object ?
  3. What kind of object serialization should I use ?
  4. How can I configure more databases (distributed or replicated database system) ?
  5. How many databases can I use in parallel ?
  6. When I create a transaction object and then I commit an update of more objects persisted to different databases, is this a distributed transaction ?
  7. How many entity adapters may I define for each type and what is the "usage" ?
  8. What is the data source associated with an entity adapter ?
  9. What are "Reference fields" and how to configure them ?
  10. What are "member descriptors" ?
  11. What are "special descriptors" ?
  12. How can I map object inheritance ?
  13. What does it mean "locking" ?
  14. How can I implement a "soft delete" ?
  15. How can I fill meta database fields ?
  16. Which data access provider (ADO) should I use ?
  17. Can I use "DADO Database Mapper®" as a database designer application ?
  18. What is the "Code generator wizard" ?
  19. Does the "Code generator wizard" create something special ?
  20. Is it possible to modify the database commands before they are sent to the database connection ?

1. How should I design my object model and what should I know ?

When creating your business object model you are not forced to any constraints. Just create your .NET objects and inheritance hierarchies, your business functions and logic. No standard naming convention, interface implementation or attributes are required. In DADO Database Mapper®  you can then map your objects to your database schema (created ex-novo or imported), configure your cache, your validation methods, and so on. So if you have an entity "Customer" create your class with your rules and that's all. In extreme case you can also persist existing compiled classes. See our example persisting standard windows forms


2. Why are two different processes to configure the serialization and to map the object ?

Even if sometime they may appear similar or an overhead, they represent two completely different processes. Serialization is the process of converting your object in a data content, independent from every data source like Xml or a database. In other words serialization tells which members, with which name and type are data content. Mapping is the process of associating serialized data with database tables and fields, depending on your schema and database rules. For example if you map your objects to Xml or an Access database for offline data elaboration and an Oracle®  or Sql server®  database for online data transactions, you should use the same serialization configuration but probably a different mapping. You can also map your objects to completely different database schemas, but the serialization should be the same. DADO Database Mapper® provides different serialization surrogates, for example one serializing all public members (properties and fields), one working only on the fields (public and private), one advanced configurable where you can define for each item a different setter or getter property/field/method, etc.. By default the serialization is the only process in DADO Solution® which works through .NET reflection. Benchmarks have shown that implementing your own serialization avoid reflection increasing object materialization speed of a factor 10.


3. What kind of object serialization should I use ?

Object serialization is the process of converting objects in abstract data to be then serialized in the underlying database. When a business object doesn't implement "System.Runtime.Serialization.ISerializable" the default serialization is based on the public properties and fields of the object; in the other case through the standard interface implementation. Implementing this interface or creating a surrogate serialization object makes your business objects faster to create (no .NET reflection is required). 


4. How can I configure more databases (distributed or replicated database system) ?

There are two ways to configure a mapping on more databases. One is just to define more databases in a single mapping configuration created with DADO Database Mapper® and then configure the entity adapters to be persisted on the different databases. The other one is to create a mapping configuration for every database and then use the DADO Broker System® to merge them in a single context.


5. How many databases can I use in parallel ?

There is no limit. Of course every database requires fix resources for the connection pooling, transaction handling, etc., so the limitations depends on your machine resources. Benchmarks have shown optimal performance even with 10 different distributed Oracle®  databases connected to the same object context. 


6. When I create a transaction object and then I commit an update of more objects persisted to different databases, is this a distributed transaction ?

When you start an update on more databases, DADO Solution® automatically updates on a different transaction for every database. If all databases involved don't report any error, all the transaction are committed sequentially, otherwise are all roll-backed. Current version of DADO Solution® don't implement a true 2 phase commit to grant 100% the success of the distributed transaction. Anyway this is planned to be realized in the next version.


7. How many entity adapters may I define for each type and what is the "usage" ?

You can define up to 4 entity adapters (mappings) for every type, that means one for every persistency operation (query, insert, update, delete). This is particular useful if you execute your operations in different database objects, for example queries through a database view and updates through a stored procedure. You can also use different adapters (mappings) if you want for example to read from one database and update another one; this is the case in a replication scenario with a master database and replicated ones.


8. What is the data source associated with an entity adapter ?

The data source associated with an entity adapter is the main database object used to retrieve and persist object's data. This can be a table, a view or a stored procedure. Having a table you map to the columns, with a view you map to the fields and with a stored procedure you map to the arguments and/or the cursor fields. In case of a table or view, once defined the main data source you can defined other joined ones (Joined sources).


9. What are "Reference fields" and how to configure them ?

Every entity object persisted as atomic unit of data must be uniquely identifiable even across database and system boundaries. This required one or more fields of the main object data source (table, view or stored procedure) to be declared as reference fields. By default reference fields are the underlying primary key(s), but this must not always be so. Of particular importance is that the reference field values don't change over time, which is in any case true for a correct database design. Avoid in any case fields which may change. Any database field combination can be used as reference fields, but having a single reference field only increase performance. If not working on a legacy database system, we suggest to create for every entity a single primary key and define this as reference field (default).


10. What are "member descriptors" ?

Member descriptors describe how serialized data items (members) are mapped to database objects. DADO Database Mapper® provides a great variety of member descriptors, from direct value mapping to n:m relationship descriptors and inline member descriptors (member mapped to a subset of current data source). For more information about member descriptors, consult DADO Database Mapper® user manual.


11. What are "special descriptors" ?

Special descriptors describe meta mapping information which is not directly loaded or related with your business object. For example it describes the handling of the Date/Time stamp, the Change Sequence, Inheritance mapping, Constant database column values, etc. For more information about special descriptors, consult DADO Database Mapper® user manual.


12. How can I map object inheritance ?

Inheritance is a very common pattern in object oriented design, but is not supported on relational databases. For this reason you can map inheritance in different ways. DADO Database Mapper® supports currently 3 ways to map inheritance on a relational schema, each one with its pros and contra. Even if there are no limitations on object hierarchies, we suggest for performance reasons to limit them to maximum 3-4 levels.


13. What does it mean "locking" ?

"Locking" is a property common to many member and special descriptors in DADO Database Mapper®. This property marks the column or field associated with given descriptor to be used in optimistic locking. Optimistic locking grants that the data updated by your objects is the same as the one which was used at object creation. This assures you against updating data which was updated in the meanwhile by someone else and loosing this way the previous update. Even if many descriptors can be used for optimistic locking, we suggest to base your optimistic locking schema only on the Date/Time stamp or Change Sequence special descriptors. 


14. How can I implement a "soft delete" ?

A soft delete is a delete operation without really deleting the underlying records, but just marking them on a special column as deleted. DADO Database Mapper® has a special descriptor called "Delete flag descriptor" which allows you to set the configuration for a soft delete. When querying data back, the object/relational mapping engine automatically appends the correct WHERE clause to filter out the soft-deleted rows.


15. How can I fill meta database fields ?

A common pattern in database design in to define meta or system columns to track meta information to your database model. If you don't want to let the database system fill them through triggers, DADO Database Mapper® provides you a great variety of predefined special descriptors for such fields, like "Username field descriptor" which fills current username, "Date/Time field descriptor" which fills the system date/time in local or UTC time, "Machine name field descriptor" which fills the name of the machine (host name), "Constant field descriptor" which fill a simple constant value, etc.. For more information about special descriptors, consult DADO Database Mapper® user manual.


16. Which data access provider (ADO) should I use ?

Even if the DADO Mapping Engine is transparently built on top of the underlying ADO.NET provider, minor differences may exist between one provider and the other, so that to get the best out of the native provider a provider adapter is required. 

DADO Mapping Engine provider adapters has been developed an tested to work on top of following data access providers:

For Sql Server: The native provider shipping with the .NET framework. No additional software required.
For Oracle: The Oracle Data Provider for .NET (ODP.NET) from Oracle Corporation. Click here to download.
For Access: The Microsoft Jet OleDb provider. If you don't have Access installed on your computer you probably need to download the Microsoft Jet OleDb provider.

17. Can I use "DADO Database Mapper®" as a database designer application ?

DADO Database Mapper® offers many advanced database designer functionalities, like table, view and stored procedure design, schema import and database generation from/to Access, Oracle and Sql-server and much more, but it is not intended to be a professional database designer tool; instead it is more oriented to the mapping functionality it must absolve, so some database system specific feature are not supported yet and other are quite generic (like constraints and indexes design). We suggest the use of "DADO Database Mapper®" as a database design tool only for the first phase of the application development process of for database prototyping.


18. What is the "Code generator wizard" ?

The code generator wizard allows you to create basic classes in C# or VB.NET from an existing database schema (tables, views or stored procedures). This is not intended to be a CASE tool (on the market there are more suitable object designer tools and code generators), but a RAD tool which allows just to create your basic classes for fast prototyping or later enhancements in your CASE or UML modeling application of choice (for example Enterprise Architect®, Rational Rose® or Software to picture®). The code generator wizard doesn't support the creation of inherited classes and relationships between them; it just generates simple classes with attributes to your database.


19. Does the "Code generator wizard" create something special ?

No. The code generator wizard just creates simple classes with private fields and public wrapper properties around the private fields. Nothing more.


20. Is it possible to modify the database commands before they are sent to the database connection ?

Yes. Every ADO command before it is sent to the database connection can be adapted (custom hook). Even if this is in most cases not required, you can implement your own command adapter (any class implementing "") and register it in DADO Solution®. DADO Solution® before executing any database command calls all registered adapters callback method passing the ADO command object to be adapted (or just logged). Following sample in VB.NET shows how to register a custom command adapter.

Imports DADO.Persistency
Imports DADO.Persistency.DatabaseAdapter

Dim MyContext As Context = Context.FromConfiguration("C:MyConfiguration.xml")
'Load a context
Dim MyDatabaseStorage As DatabaseStorage =
  MyContext.StorageManager.Get("MyDatabaseName") 'Get a defined database
MyDatabaseStorage.CommandAdapters.Add(MyCommandAdapter)



  1. Welcome
  2. Introduction
  3. About O/R mapping
  4. Advantages
  5. Architectures
  6. Download
  7. Sample code
  8. Demos & Samples
  9. Purchase
  10. Facts & Figures
  11. FAQ's
  12. Press room
  13. Impressum



  14. USEFUL LINKS
    MSDN Downloads
    www.dotnet247.com
    MSDN Subs
    GotDotNet
    www.asp.net
    Microsoft .NET Oracle Microsoft Access Microsoft SQL Server

    Contact us:
    Technical support, Sale information, Questions



    Copyright © 2004 DADO Solution. All rights reserved.