TechTalk Genome v4.2

Database Type Modifiers

The mapping of scalar types to database types in the underlying relational database system can be influenced by using the database type modifier attributes. The attributes can be used for the following types:

Examples

The following example illustrates how to use database type modifiers to define the type of a persistent field in the database.

          
Employee.cs
                    
public abstract class Employee : Persistent {
    ...
    public abstract string FirstName { get; set; }
    public abstract DateTime BirthDate { get; set; }
    public abstract string HomePhone { get; set; }
}
                    
          
NorthwindSchema.xml    
                    
<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">
    ...

    <Type name="Employee">
        ...
    
        <!-- FirstName will be stored in the "FirstName nvarchar(255)" field -->
        <Member name="FirstName">
            <PersistentField />
        </Member>
        
        <!-- BirthDate will be stored in the "dtBirthDate datetime" field -->
        <Member name="BirthDate" PersistentField="dtBirthDate" />   

        <!-- HomePhone will be stored in the "strPhone varchar(24)" field -->
        <Member name="HomePhone">
            <PersistentField fieldName="strPhone" Length="24" Unicode="false" />
        </Member>

    </Type>
    
</Mapping>
                    

See Also

XmlMapping.Elements.PersistentField | <StoredFunction> Element