A map is a very simple concept being just a link between a table column in a DataSet and a public field or property of a domain object. Mappers will contain a collection of one or more of these maps. A map contains just one optional property; the name of the matching table column. This is only required when the appropriate column name does not match the property name, otherwise the name of the map is taken to be both the property name and column name.

An interesting feature with maps is that there does not need to be an exact match with the set of domain object properties or the columns of the DTO tables. If a property matches a map and there is a column for it in the DTO table then a mapping action ocurrs. Any maps not matched with a property or a column will be ignored. This feature is used to effect especially with Super Mappers where the collection of maps has to be the set of all possible maps for any of the super types. So, therefore, for any individual super type, typically the set of public fields and properties will not match with every single map, there will either be the same number of maps to public properties or more maps than public properties. All additional maps that do not match with a public field or property are ignored. Conversely, additional columns in the DTO table that are not matched with a public field or property are ignored and if a column does not exist for a map then that public field or property will simply remain empty.

The MAB supports just one map type: Map plus the Custom Map for user extensions to other map types.

Custom Maps

It is quite likely that a situation could arise where a map convention is required that is not supported. An example might include the concatenation of two columns into one property of a domain object. For example your table might contain Firstname and Surname columns but the domain object simply has one Name property to hold the concatenated Firstname and Surname pair. For this you can create a custom map by implementing the IMap interface. For more details refer to the Extending the Mapping Application Block page.

Last edited Jun 16, 2010 at 8:03 AM by ewdev, version 3


No comments yet.