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

AF SDK Reference

AFCategory Class

  • Last UpdatedNov 18, 2025
  • 8 minute read
AFCategory Class
The AFCategory represents a user-defined value used to categorize objects within the AF SDK. Use it to group objects by categories when generating reports or when making queries.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AFAFCategory

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

Syntax

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

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

The AFCategory type exposes the following members.

Constructors

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

Properties

  NameDescription
Public property
CheckOutInfo
This read-only property returns the checked out status information for the object.
Public property
Database
This read-only property returns the AFDatabase where this object is defined.
Public property
Description
Read/write property that provides a more detailed description of the object.
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 propertyStatic member
None
An AFCategory that represents no category.
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
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
CheckOutCategories
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
DeleteCategories
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
FindCategory
Retrieves the AFCategory object with the specified unique identifier.
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
LoadCategories
Loads the AFCategory objects with the specified unique identifiers.
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 collections of available categories are maintained by the AFDatabase. There are separate collections of categories defined for the following objects: AFElementTemplateAFBaseElement, AFAttributeTemplate, AFAttribute, AFReferenceType, AFTable, AFAnalysisTemplate, and AFAnalysis. The AFDatabase.ElementCategories collection is used for AFElementTemplate objects and all derived objects of AFBaseElement. The AFDatabase.AnalysisCategories collection is used for AFAnalysisTemplate and AFAnalysis objects.

Create a new AFCategory object by calling one of the AFCategoriesAdd methods of the desired collection maintained by the AFDatabase.

Examples

// This example demonstrates how to create an element category and display its information.
// It also shows how to set the category for an element template.

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

// Create the Category
AFCategory myCategory = myDB.ElementCategories.Add("MyElementCategory");
myCategory.Description = "This is my Element Category";

// Display the Name and Description of the Category
Console.WriteLine("Name of Category = {0}", myCategory.Name);
Console.WriteLine("Description = {0}", myCategory.Description);

// Create an Element Template
AFElementTemplate myElemTemplate = myDB.ElementTemplates.Add("MyElementTemplate");

// Set the Category for an Element Template
myElemTemplate.Categories.Add(myCategory);
' This example demonstrates how to create an element category and display its information.
' It also shows how to set the category for an element template.

' Get the Database
Dim myPISystems As New PISystems
Dim myDB As AFDatabase = myPISystems.DefaultPISystem.Databases.DefaultDatabase

' Create the Category
Dim myCategory As AFCategory = myDB.ElementCategories.Add("MyElementCategory")
myCategory.Description = "This is my Element Category"

' Display the Name and Description of the Category
Console.WriteLine("Name of Category = {0}", myCategory.Name)
Console.WriteLine("Description = {0}", myCategory.Description)

' Create an Element Template
Dim myElemTemplate As AFElementTemplate = myDB.ElementTemplates.Add("MyElementTemplate")

' Set the Category for an Element Template
myElemTemplate.Categories.Add(myCategory)

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK


See Also

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