When ECO builds the O/R mapping layer, it has to decide how to convert the values of the database
column to the values of the attributes in the ecospace. This is
performed by an attribute mapper, and the O/R mapping layer has to
decide which attribute mapper to use for each attribute. To decide this, there is the
collection PersistenceMapper.SqlDatabaseConfig.PersistenceMappers. This
contains of a collection of name/mapper pairs. The name is normally the
CLR-name of a type (such as System.String or System.DateTime), but
can be anything. The algorithm for deciding the mapper for an attribute
is to look for an attribute mapper in the following order:
- the Tagged Value "PMapper" on the attribute
- The string "ClassName.AttributeName"
- The CLR-name of the type of the attribute
If you want to replace the mapper for all DateTime attributes, then all
you need to do is to create your new mapper, and fit it into the
collection with the name System.DateTime. The attribute mapper
controls the following things:
- how to convert from db to memory and back
- the sql type of the column if we need to generate or evolve a db
- the default db value (practically only used when evolving)
- converting a value to a string literal
The source for all the attribute mappers in eco is included, and often, the easiest thing is to copy an existing mapper for the same datatype and modify it to suite your needs.