TechTalk Genome v4.2

<CheckIntegrity> Element

Notifies Genome to create and handle foreign keys between tables in the database.

<Member name=" property ">
<NearObjectReference [ CheckIntegrity="true|false" ] />
</Member>

or

<Member name=" property ">
<NearObjectReference>
<CheckIntegrity [ enabled="true|false" ] [constraintName="constraint-name"] />
</NearObjectReference>
</Member>

or

<Type name=" type ">
<JoinedInheritance [ CheckIntegrity="true|false" ] />
</Type>

or

<Type name=" type ">
<JoinedInheritance>
<CheckIntegrity [ enabled="true|false" ] [constraintName="constraint-name"] />
</JoinedInheritance>
</Type>
type
A type specifying a persistent class.
property
A property referring to a persistent type. The property can have getter or setter or both.
enabled
If true, referential integrity is enforced with a foreign key constraint in the database. In this case, the Genome engine ensures that the SQL commands are executed in an appropriate order so that the foreign key constraint is not violated. The database creation script generated by schema compiler will contain creation commands for the foreign key constraint as well. If false, referential integrity is ensured for the entire transaction only, but not ensured after each SQL command. The default value is <CheckIntegrity enabled="true" />.
constraint-name
The name of the foreign key constraint. The maximum length of the foreign key constraint name depends on the database platform (Microsoft SQL Server: 128; Oracle: 30; DB2: 18). The default value is <long name of type>.<member name>, stripped to the platform-dependent maximum value.

Remarks

Genome naturally ensures referential integrity as a simple consequence of the strongly typed object model. Please note that referential integrity might be temporarily violated during the transaction, although it is not violated at the end of the entire transaction. Setting CheckIntegrity notifies Genome that there might be a foreigh key constraint in the database that must not be violated during the transaction, either. Please note that setting CheckIntegrity for references causes a performance penalty. In this case, commands of the transaction have to be ordered in an appropriate way so that the foreign key constraints are not even temporally violated.

When applied on a NearObjectReference element, the foreign key is created such that it points from the referring field on the persistent type's table to the primary key fields of the referred type's table.

When applied on a JoinedInhertance element, the foreign key is created such that it points from the primary key on the persistent type's table to the primary key fields of the base type's table.

If the CheckIntegrity element is omitted, the default CheckIntegrity value of the parent element is false, as if <NearObjectReference checkIntegrity="false" />, or <JoinedInheritance checkIntegrity="false" /> had been specified.

Examples

          
Order.cs
                
public abstract class Shipper : Persistent {
    ...
    public abstract int Id { get; set; }
}

public abstract class Order : Persistent {
    ...
    public abstract Shipper ShipVia { get; set; }
}
                
          
NorthwindSchema.xml    
                
<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">
    ...

    <Type name="Shipper">
        ...

        <PrimaryKey><Key>Id</Key></PrimaryKey>
        
        <Member name="Id" PersistentField="SNr" />
    </Type>
    
    <Type name="Order">
        ...
    
        <!-- the ShipVia reference will be enforced, using foreign key "Order.ShipVia" -->
        <Member name="ShipVia">
            <NearObjectReference CheckIntegrity="true"/>
        </Member>

        - or -

        <!-- the ShipVia reference will be enforced, using foreign key "FK_ShipVia_Shipper" -->
        <Member name="ShipVia">
            <NearObjectReference>
                <CheckIntegrity enabled="true" constraintName="FK_ShipVia_Shipper" />
            </NearObjectReference>
        </Member>
        
        - or -
        
        <!-- CheckIntegrity attribute is omitted, the ShipVia reference won't be enforced -->
        <Member name="ShipVia">
            <NearObjectReference />
        </Member>
    </Type>
    
</Mapping>
                

Requirements

Type: TechTalk.Genome.Mapping.CheckIntegrityXmlData

Assembly: TechTalk.Genome.dll

Version: 4.2.11

Editions: Professional, Evaluation, Express

Database Platforms: Microsoft SQL Server 2000, Microsoft SQL Server 2005, Oracle 9i Release 2, Oracle 10g Release 2

See Also

<NearObjectReference> Element | <JoinedInheritance> Element