Click or drag to resize

IRelationship Interface

The representation of a relationship between two objects.

Namespace:  PDTec.IceNet.Core.Model
Assembly:  PDTec.IceNet.Core (in PDTec.IceNet.Core.dll) Version: 7.2.0.0 (7.2.7583.15464)
Syntax
C#
public interface IRelationship

The IRelationship type exposes the following members.

Properties
  NameDescription
Public propertyChangedBy
The name of the user who changed the relationship last.
Public propertyChangedOn
The point of time the relationship was changed last.
Public propertyCreatedBy
The name of the user who created the relationship.
Public propertyCreatedOn
The point of time the relationship was created.
Public propertyDescription
The relationship description. The description can be empty.
Public propertyId
The relationship ID. The ID is generated by the platform and cannot be modified.
Public propertyIsValid
Indicates if the relationship instance is valid. The relationship becomes invalid if the Destroy method is called or if an associated object has been destroyed.
Public propertyObjectFrom
Gets the referenced object in From direction.
Public propertyObjectTo
Gets the referenced object in To direction.
Public propertyRelType
Gets the relationship type.
Top
Methods
  NameDescription
Public methodDestroy
Deletes the relationship.
Public methodGetAttrValue(String)
Retrieves the specified attribute value.
Public methodGetAttrValue(IRelAttrDef)
Retrieves the specified attribute value.
Public methodGetAttrValue(String, Boolean) Obsolete.
Retrieves the specified attribute value and indicates if the value is assigned.
Public methodGetAttrValue(IRelAttrDef, Boolean) Obsolete.
Retrieves the specified attribute value and indicates if the value is assigned.
Public methodGetAttrValues
Get all attribute values of the relationship.
Public methodGetObject
Retrieves the associated object in the specified direction.
Public methodGetRelType
Retrieve the relationship type.
Public methodReload
Refreshes the relationship data from secondary storage (e.g. database) if available. Use this method to retrieve up-to-date audit information (ChangedBy, ChangedOn properties).
Public methodSetAttrValue(String, Object)
Stores the specified attribute value.
Public methodSetAttrValue(IRelAttrDef, Object)
Stores the specified attribute value.
Public methodSetAttrValues
Set multiple attribute values with a single method call.
Public methodTouch
Updates the ChangedBy and ChangedOn information.
Public methodTryGetAttrValue(String, Boolean)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(String, DateTime)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(String, Double)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(String, Int64)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(String, Object)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(String, String)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(IRelAttrDef, Boolean)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(IRelAttrDef, DateTime)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(IRelAttrDef, Double)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(IRelAttrDef, Int64)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(IRelAttrDef, Object)
Attempts to get the specified attribute value and indicates if the value is assigned.
Public methodTryGetAttrValue(IRelAttrDef, String)
Attempts to get the specified attribute value and indicates if the value is assigned.
Top
Examples

This example shows how to create relationships.

C#
IObject pBooking = Repository.GetObject(objectId);
IObject pVehicle = Repository.GetObject(vehicleId);

IRelType pRelType = Repository.GetRelTypeByName("PDTec.ICR.BookedVehicle");

Repository.ExecuteTransaction(delegate()
{
    // Create a relationship between the two objects...
    IRelationship pRelationship = pRelType.CreateRelationship(pBooking, pVehicle, "");

    // ...[do something with the new relationship]...

});

This example shows how to navigate relationships.

C#
IObject pCustomer = Repository.GetObject(customerId);

IRelationship[] aRelationships = pCustomer.GetRelationships(
    "PDTec.ICR.CustomerBookings",
    RelDirection.Forward);

foreach (IRelationship pRelationship in aRelationships)
{
    IObject pBooking = pRelationship.ObjectTo;

    // ...[do something with the booking]...

    IRelationship pRelationshipVehicle = pBooking.GetSingleRelationship(
        "PDTec.ICR.BookedVehicle",
        RelDirection.Forward);

    IObject pVehicle = pRelationshipVehicle.ObjectTo;    

    // ...[do something with the booked vehicle]...
}

This example shows how to use the TryGetSingleRelationship(String, RelDirection, IRelationship) method to avoid an exception when no matching relationship is attached to the object.

C#
IObject pBooking = Repository.GetObject(bookingId);

// ...[do something with the booking]...

IRelationship pRelationshipVehicle;
if (pBooking.TryGetSingleRelationship("PDTec.ICR.BookedVehicle", RelDirection.Forward, out pRelationshipVehicle))
{
    IObject pVehicle = pRelationshipVehicle.ObjectTo;    

    // ...[do something with the booked vehicle]...
}
See Also