Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFReferenceType Class

  • Last UpdatedJan 12, 2026
  • 10 minute read
AFReferenceType Class
An AFReferenceType specifies a relationship type to use when making a hierarchical relationship between two elements.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AF.AssetAFReferenceType

Namespace:  OSIsoft.AF.Asset
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.2.0.7

Syntax

[SerializableAttribute]
public sealed class AFReferenceType : AFObject, 
	IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable<AFReferenceType>
<SerializableAttribute>
Public NotInheritable Class AFReferenceType
	Inherits AFObject
	Implements IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable(Of AFReferenceType)

Dim instance As AFReferenceType
[SerializableAttribute]
public ref class AFReferenceType sealed : public AFObject, 
	IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable<AFReferenceType^>
[<SealedAttribute>]
[<SerializableAttribute>]
type AFReferenceType =  
    class
        inherit AFObject
        interface IAFTransactable
        interface IAFChangedEvent
        interface IAFSecurable
        interface IComparable<AFReferenceType>
    end

The AFReferenceType type exposes the following members.

Constructors

  NameDescription
Public method
AFReferenceType
Initializes a new instance of the class with default values.
Public method
AFReferenceType(String, String, String)
Initializes a new instance of the class with the specified name.

Properties

  NameDescription
Public property
AllowedChildElementTemplate
This property is the AFElementTemplate of the elements which can be used in the child half of the relationship.
Public property
AllowedParentElementTemplate
This property is the AFElementTemplate of the elements which can be used in the parent half of the relationship.
Public property
Categories
This is a user-defined collection of categories for the object that can be used for querying and/or reporting purposes.
Public property
CategoriesString
This read-only property returns the list of categories in a string separated by semicolons.
Public property
CheckOutInfo
This read-only property returns the checked out status information for the object.
Public property
ChildName
Read/write property that is the name of the relation from the parent element to the child element.
Public property
Database
This read-only property returns the AFDatabase where this object is defined.
Public property
ID
Read-only property that provides a unique identifier for the object to be used for quick access that is not dependent upon the index.
(Inherited from AFObject.)
Public property
Identity
This read-only property contains identity of the object.
(Inherited from AFObject.)
Public property
IsDeleted
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.)
Public property
IsDirty
This read-only property indicates whether the object has been modified since the last save to the PI AF Server.
Public property
IsNew
This read-only property indicates whether the object is new and has never been saved to the PI AF Server.
Public property
Name
Read/write property that identifies the name of the object.
Public property
ParentName
Read/write property that is the name of the relation from the child element to the parent element.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
Security
This read-only property returns the AFSecurity information for the object.
Public property
Strength
Read/write property which indicates the strength of the relationship.
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)

Methods

  NameDescription
Public methodCode example
ApplyChanges
This method applies the changes to the object and makes those changes available to other objects for the current user.
Public methodCode example
CheckIn
This method checks in (commits) all the changes to the object by saving the information to persistent storage.
Public method
CheckOut
This method locks the object so that its configuration can be modified.
Public methodStatic member
CheckOutReferenceTypes
Check out the objects with the specified unique identifiers at the specified query date.
Public method
CompareTo(Object)
Compares this instance with a specified Object.
(Inherited from AFObject.)
Public method
CompareTo(AFObject)
Compares this instance with a specified AFObject.
(Inherited from AFObject.)
Public methodStatic member
DeleteReferenceTypes
Delete the objects with the specified unique identifiers.
Public method
Equals(Object)
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.)
Public method
Equals(AFObject)
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.)
Public methodStatic member
FindReferenceType(PISystem, Guid)
Retrieves the AFReferenceType object with the specified unique identifier at the AFTime.MaxValue query date.
Public methodStatic member
FindReferenceType(PISystem, Guid, Object)
Retrieves the AFReferenceType object with the specified unique identifier at the specified query date.
Public methodStatic member
FindReferenceTypes
Performs a search within the PISystem to retrieve a collection of AFReferenceType objects with the specified list of unique identifiers.
Public method
GetHashCode
Gets the hash code for this instance of the object which is suitable for use in hashing algorithms and data structures like a hash table.
(Inherited from AFObject.)
Public method
GetPath
Returns the full path to the object, using just the names.
(Inherited from AFObject.)
Public method
GetPath(AFObject)
Returns the path to the object relative from another object.
(Inherited from AFObject.)
Public method
GetPath(AFEncodeType, AFObject)
Returns the path to the object relative from another object, using the name and/or id as specified by encodeType.
(Inherited from AFObject.)
Public method
GetSecurity
Gets the AFSecurity information of the specified security item associated with the object.
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic member
LoadReferenceTypes(IListAFReferenceType)
Loads the specified list AFReferenceType objects.
Public methodStatic member
LoadReferenceTypes(PISystem, Guid)
Loads the AFReferenceType objects with the specified unique identifiers at the AFTime.MaxValue query date.
Public methodStatic member
LoadReferenceTypes(PISystem, Guid, Object)
Loads the AFReferenceType objects with the specified unique identifiers at the specified query date.
Public method
Persist
This method returns the persistence string for the object.
(Inherited from AFObject.)
Public method
Refresh
Refreshes the client with any changes that have been made to the object since loaded.
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)
Public method
UndoCheckOut
This method discards all the changes to the object and all sub-objects since the last call to CheckOut. Any changes since the check out will be lost.

Events

  NameDescription
Public eventCode example
Changed
Event is raised when the object or one of its sub-objects is changed.

Remarks

The reference types are defined at the AFDatabase level. The AFReferenceType defines the ways in which two AFElement objects can relate to each other. The reference types are named and are always hierarchical. If the user chooses not to make use of a reference type, then the SDK will automatically use the default system defined reference type which enforces a "Parent-Child" relationship.

Three fundamental reference type strengths are available: Strong, Weak, and Composition. A strong reference means that in the absence of a composition parent, an AFElement will exist as long as it has one or more strongly related parents. A weak reference is used when the parent does not want to define the lifetime of a child element. A composition reference means that the parent element solely defines and owns the child element. In a composition relationship, a child element may only be contained by one composition parent and deleting the parent will delete the child element.

The SDK provides the following system defined reference types:

NameDescription
Parent-Child Defines a 'n..n' strong reference type which will be used to create hierarchical relationships. This is the default reference type when no reference type is specified. This reference type additionally requires unique names.
Composition Defines a '1..n' composition reference type which will be used to create compositional hierarchies.
Weak Reference Defines a 'n..n' weak reference type.

Additional reference types can be defined by applications or the user. This will allow applications to build application specific hierarchies of elements using a more specific relation. It will also allow applications to define or override the specifics of how element relations behave.

Examples

// This example demonstrates how to create some element templates and reference types.
// Then it will use these reference types to define a hierarchy.

// Get the Database
PISystems myPISystems = new PISystems();
AFDatabase myDB = myPISystems.DefaultPISystem.Databases.DefaultDatabase;

// Create Element Templates for Hierarchy
AFElementTemplate plantTempl = myDB.ElementTemplates.Add("PlantTemplate");
AFElementTemplate unitTempl = myDB.ElementTemplates.Add("UnitTemplate");
AFElementTemplate deviceTempl = myDB.ElementTemplates.Add("DeviceTemplate");
AFElementTemplate pumpTempl = myDB.ElementTemplates.Add("PumpTemplate");
pumpTempl.BaseTemplate = deviceTempl;
AFElementTemplate valveTempl = myDB.ElementTemplates.Add("ValveTemplate");
valveTempl.BaseTemplate = deviceTempl;

// Create Reference Types Necessary for Hierarchy
AFReferenceType unitRefType = myDB.ReferenceTypes.Add("Unit", "Units", "Plant");
unitRefType.Strength = AFReferenceStrength.Strong;
unitRefType.AllowedParentElementTemplate = plantTempl;
unitRefType.AllowedChildElementTemplate = unitTempl;

AFReferenceType deviceRefType = myDB.ReferenceTypes.Add("Device", "Devices", "Unit");
deviceRefType.Strength = AFReferenceStrength.Strong;
deviceRefType.AllowedParentElementTemplate = unitTempl;
deviceRefType.AllowedChildElementTemplate = deviceTempl;

// Create Hierarchy of Elements
AFElement plant1 = myDB.Elements.Add("Plant#1", plantTempl);
AFElement unit1 = plant1.Elements.Add("Unit#1", unitTempl, unitRefType);
AFElement pump1 = unit1.Elements.Add("Pump#1", pumpTempl, deviceRefType);
AFElement pump2 = unit1.Elements.Add("Pump#2", pumpTempl, deviceRefType);
AFElement valve1 = unit1.Elements.Add("Valve#1", valveTempl, deviceRefType);
myDB.CheckIn();

// Find Elements by Reference Type
var search = new AFElementSearch(myDB, "FindElements", @"Root:'Plant#1\Unit#1' ReferenceType:'Device' AllDescendants:False");
int count = 0;
foreach (var item in search.FindObjects())
{
    count++;
    Console.WriteLine("Device: {0}", item);
}

Version Information

AFSDK


See Also

TitleResults for “How to create a CRG?”Also Available in