AFReferenceType Class
- Last UpdatedJan 12, 2026
- 10 minute read
- PI System
- AF SDK 3.2.0
- Developer

Inheritance Hierarchy
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
| Name | Description | |
|---|---|---|
| AFReferenceType |
Initializes a new instance of the class with default values.
| |
| AFReferenceType(String, String, String) |
Initializes a new instance of the class with the specified name.
|
Properties
| Name | Description | |
|---|---|---|
| AllowedChildElementTemplate |
This property is the AFElementTemplate of the elements which can be used
in the child half of the relationship.
| |
| AllowedParentElementTemplate |
This property is the AFElementTemplate of the elements which can be used
in the parent half of the relationship.
| |
| Categories |
This is a user-defined collection of categories for the object that can be used for
querying and/or reporting purposes.
| |
| CategoriesString |
This read-only property returns the list of categories in a string separated by semicolons.
| |
| CheckOutInfo |
This read-only property returns the checked out status information for the object.
| |
| ChildName |
Read/write property that is the name of the relation from the parent element
to the child element.
| |
| Database |
This read-only property returns the AFDatabase where this object is defined.
| |
| 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.) | |
| Identity |
This read-only property contains identity of the object.
(Inherited from AFObject.) | |
| IsDeleted |
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.) | |
| IsDirty |
This read-only property indicates whether the object has been modified since the
last save to the PI AF Server.
| |
| IsNew |
This read-only property indicates whether the object is new and has never been saved
to the PI AF Server.
| |
| Name |
Read/write property that identifies the name of the object.
| |
| ParentName |
Read/write property that is the name of the relation from the child element
to the parent element.
| |
| PISystem |
This read-only property allows access to the PISystem associated with this
object.
(Inherited from AFObject.) | |
| Security |
This read-only property returns the AFSecurity information for the object.
| |
| Strength |
Read/write property which indicates the strength of the relationship.
| |
| UniqueID |
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.) |
Methods
| Name | Description | |
|---|---|---|
| ApplyChanges |
This method applies the changes to the object and makes
those changes available to other objects for the current user.
| |
| CheckIn |
This method checks in (commits) all the changes to the object by saving
the information to persistent storage.
| |
| CheckOut |
This method locks the object so that its configuration can be modified.
| |
| CheckOutReferenceTypes |
Check out the objects with the specified unique identifiers at the specified query date.
| |
| CompareTo(Object) |
Compares this instance with a specified Object.
(Inherited from AFObject.) | |
| CompareTo(AFObject) |
Compares this instance with a specified AFObject.
(Inherited from AFObject.) | |
| DeleteReferenceTypes |
Delete the objects with the specified unique identifiers.
| |
| Equals(Object) |
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.) | |
| Equals(AFObject) |
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.) | |
| FindReferenceType(PISystem, Guid) |
Retrieves the AFReferenceType object with the specified unique identifier
at the AFTime.MaxValue query date.
| |
| FindReferenceType(PISystem, Guid, Object) |
Retrieves the AFReferenceType object with the specified unique identifier
at the specified query date.
| |
| FindReferenceTypes |
Performs a search within the PISystem to retrieve a collection
of AFReferenceType objects with the specified list of unique identifiers.
| |
| 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.) | |
| GetPath |
Returns the full path to the object, using just the names.
(Inherited from AFObject.) | |
| GetPath(AFObject) |
Returns the path to the object relative from another object.
(Inherited from AFObject.) | |
| 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.) | |
| GetSecurity |
Gets the AFSecurity information of the specified security item
associated with the object.
| |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| LoadReferenceTypes(IListAFReferenceType) |
Loads the specified list AFReferenceType objects.
| |
| LoadReferenceTypes(PISystem, Guid) |
Loads the AFReferenceType objects with the specified unique identifiers
at the AFTime.MaxValue query date.
| |
| LoadReferenceTypes(PISystem, Guid, Object) |
Loads the AFReferenceType objects with the specified unique identifiers
at the specified query date.
| |
| Persist |
This method returns the persistence string for the object.
(Inherited from AFObject.) | |
| Refresh |
Refreshes the client with any changes that have been made to the object since loaded.
| |
| ToString |
Returns a String that represents the current object.
(Inherited from AFObject.) | |
| 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
| Name | Description | |
|---|---|---|
| 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:
| Name | Description |
|---|---|
| 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); }