Stores a reference to a persistent type in one or more database fields.
or
or
The <NearObjectReference> element can be used to store a property that refers to an object in the same DataDomain. NearObjectReference creates a foreign key field for every primary key field of the referred type.
The field-prefix can be used to name foreign keys by prefixing the foreign keys with field-prefix. The <Map> element can be used to achieve one-by-one naming for each primary key field. When using one-by-one naming, all primary key fields have to be mapped to a foreign key field. The type of the created database fields is inherited from the identity fields of the referred type.
If the property of an object refers to another object, then all foreign key fields have to
contain an non-
NULL
value. If the property does not refer to any
object, then all foreign key fields have to contain a database
NULL
value and the property
contains a null reference.
A property mapped with PersistentField can be used in C# code and OQL expressions. The property is implemented by accessing the object state in the Context associated with the object.
When mapping to read-only databases, the setter of the property can be omitted.
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 stored in the "ShipViaSNr int" PK field -->
<Member name="ShipVia">
<NearObjectReference />
</Member>
- or -
<!-- the ShipVia reference will be stored in the "ShipperSNr int" PK field -->
<Member name="ShipVia" NearObjectReference="Shipper" />
- or -
<!-- the ShipVia reference will be stored in the "SHP int" PK field -->
<Member name="ShipVia">
<NearObjectReference>
<Map primaryKeyName="SNr" foreignKeyName="SHP" />
</NearObjectReference>
</Member>
</Type>
</Mapping>
Type: TechTalk.Genome.Mapping.NearObjectReferenceXmlData
Assembly: TechTalk.Genome.dll
Version: 4.2.4
Editions: Professional, Evaluation, Express
Database Platforms: Microsoft SQL Server 2000, Microsoft SQL Server 2005, Oracle 9i Release 2, Oracle 10g Release 2
Field Mappings | XmlMapping.Elements.PersistentField | <Ignore> Element | <CheckIntegrity> Element