TechTalk Genome v4.2

<EnumMapping> Element

Specifies how Genome should map enumeration values to the database.

<Type name=" enumType ">
<EnumMapping baseType=" clr-type " [database-type-modifiers] >
<Value enumValue="enum-value1" dbValue="db-value1">
<Value enumValue="enum-value2" dbValue="db-value2">
The name of an enumeration type.
The type of values specified as db-value*.
An optional list of database type modifiers that change the type of the database field. The default mapping for the type of clr-type is used if no modifier is specified. The defaults can be found in the description of Database Type Modifiers.
enum-value1, enum-value2, ...
Values of the enumType enumeration.
db-value1, db-value2, ...
Values stored in the database that represent the client side enumeration value of the corresponding enum-value*.


This feature modifies the mapping of the enumType globally in the whole schema, meaning that all enumType fields of the business classes that are mapped as PersistentField are affected.

For each the enumeration value of enumType, there should be exactly one <Value .../> element defined. Also, all the mapped database values (db-value1, db-value2, ...) should be different.


Mapping the values of the Color class

public enum Color
as varchar(2), with the values "R", "G", "B" and "BK" respectively:
<?xml version="1.0" ?>

<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">
  <Using namespace="System" />
  <Using namespace="TechTalk.Genome" />
  <Using namespace="TechTalk.Genome.Mapping" />
  <Using namespace="TechTalk.Genome.Schema.Builder.Xml" />
  <Using namespace="MyBusiness" />
  <Type name="Color">
    <EnumMapping baseType="string" Unicode="false" VariableLength="true" Length="2">
      <Value enumValue="Red" dbValue="R" />
      <Value enumValue="Green" dbValue="G" />
      <Value enumValue="Blue" dbValue="B" />
      <Value enumValue="Black" dbValue="BK" />

See Also

Other Elements