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

AF SDK Reference

AFDatabase Class

  • Last UpdatedNov 18, 2025
  • 11 minute read
AFDatabase Class
The AFDatabase represents a single database (data archive) in a PI AF Server.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AFAFDatabase

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

Syntax

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

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

The AFDatabase type exposes the following members.

Properties

  NameDescription
Public property
Analyses Obsolete.
Gets the collection of analyses maintained by the AFDatabase.
Public property
AnalysisCategories
Gets the collection of analysis categories maintained by the AFDatabase.
Public property
AnalysisTemplates
Gets the collection of top-level pre-configured analysis rule template maintained by the AFDatabase.
Public property
AttributeCategories
Gets the collection of attribute categories maintained by the AFDatabase.
Public property
DefaultPIServerName
This property is the name of the default PIServer for this AFDatabase.
Public property
Description
Read/write property that provides a more detailed description of the object.
Public property
ElementCategories
Gets the collection of element categories maintained by the AFDatabase.
Public property
Elements
Gets the collection of top-level elements maintained by the AFDatabase.
Public property
ElementTemplates
Gets the collection of element templates maintained by the AFDatabase.
Public property
EnumerationSets
Gets the collection of enumerations maintained by the AFDatabase.
Public property
ExtendedProperties
A dictionary of extended properties that can be used to store application specific information.
Public property
HasItemsCheckedOut
Determines if any items are currently checked out in the AFDatabase.
Public property
HasItemsCheckedOutToMe
Determines if any items are currently checked out to the current user in the AFDatabase.
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
Indicates whether there are objects in the AFDatabase that have been modified since the last save in to persistent storage.
Public property
ModifyDate
This read-only property returns the time when any object within the database was last modified.
Public property
Name
This read/write property is the name that identifies the AFDatabase on the local machine.
Public property
NotificationRuleCategories
Gets the collection of analysis categories maintained by the AFDatabase.
Public property
Notifications Obsolete.
Gets the collection of top-level notifications maintained by the AFDatabase.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
QueryDate
This read-only property returns the date used to retrieve the version of an object.
Public property
ReferenceTypeCategories
Gets the collection of reference type categories maintained by the AFDatabase.
Public property
ReferenceTypes
Gets the collection of reference types maintained by the AFDatabase that can be used when defining relationships between elements.
Public property
Security
This read-only property returns the AFSecurity information for the object.
Public property
TableCategories
Gets the collection of element categories maintained by the AFDatabase.
Public property
TableConnections
This property provides access to the table connection collection, which you can use to access external tables of user-defined information.
Public property
Tables
This property provides access to the table database, which you can use to define and/or access tables of user-defined information.
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)

Methods

  NameDescription
Public method
AddTransfer(String)
Creates a new AFTransfer without specifying a template.
Public method
AddTransfer(String, AFElementTemplate)
Creates a new transfer based upon the specified template.
Public methodCode example
ApplyChanges
This method applies (saves) all the changes to objects modified by the current user in the database and makes those changes available to other applications executing under the same user account.
Public methodCode example
ApplyChanges(AFCheckedOutMode)
This method applies (saves) the changes to objects in the database according to the specified AFCheckedOutMode and makes those changes available to other applications executing under the same user account.
Public method
ApplyQueryDate
Applies the specified query date to the current object and returns an object in the new context.
Public methodCode example
CheckIn
This method checks in (commits) all the changes to all objects modified by the current user in the database by saving all information to persistent storage.
Public methodCode example
CheckIn(AFCheckedOutMode)
This method checks in (commits) all the changes to the objects in the database according to the specified AFCheckedOutMode.
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 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 methodCode example
FindChangedItems(Boolean, AFTime, AFTime) Obsolete.
Find all the items that have changed in the AFDatabase.
Public methodCode example
FindChangedItems(Boolean, Int32, Object, Object)
Find all the items that have changed in the AFDatabase.
Public methodCode example
FindChangedItems(AFIdentity, Boolean, AFTime, AFTime) Obsolete.
Find all the items that have changed in the AFDatabase of the specified type.
Public methodCode example
FindChangedItems(AFIdentity, Boolean, Int32, Object, Object)
Find all the items that have changed in the AFDatabase of the specified type.
Public method
FindCheckedOutItems(Boolean)
This method finds all the items that are currently checked out in the AFDatabase.
Public method
FindCheckedOutItems(AFCheckedOutMode)
This method finds the items that are currently checked out in the AFDatabase according to the specified AFCheckedOutMode.
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 method
Persist
This method returns the persistence string for the object.
(Inherited from AFObject.)
Public methodCode example
Refresh
Refreshes the client with any changes that have been made to the database since loaded without discarding unapplied changes.
Public methodCode example
Refresh(Boolean)
Refreshes the client with any changes that have been made to the database since loaded with an option to discard unapplied changes.
Public method
RemoveTransfer
Removes an existing AFTransfer from the database.
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)
Public method
UndoCheckOut
Rolls back all the changes to the database since the last call to the CheckOut method of each object. 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 database stores its information in a PI AF Server. AFDatabase objects are retrieved from the AFDatabases collection and provide access to the basic entities represented on each database, such as element templates, elements, tables, etc.

Typically, a program requires a network connection to the server where the database is located. Connections are established by calling one of the PISystemConnect methods. The PISystem.Disconnect method is used to break the connection to the database.

Many of the services available through the AFDatabase are accessed through its properties, which return other objects. For example, the Elements property provides a collection of elements for accessing the defined elements on a database.

Examples

// This example demonstrates how to use several properties of the AFDatabase object.

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

// Display information about the Default DB
Console.WriteLine("Name of Default DB = {0}", myDB.Name);
Console.WriteLine("Description of Default DB = {0}", myDB.Description);
Console.WriteLine("UniqueID of DefaultDB = {0}", myDB.UniqueID);

// Set the DB to the First DB
myDB = myPISystem.Databases[0];

// Display the Name, Description, and UniqueID of the first db
Console.WriteLine("Name of First DB = {0}", myDB.Name);
Console.WriteLine("Description of First DB = {0}", myDB.Description);
Console.WriteLine("UniqueID of First DB = {0}", myDB.UniqueID);

// Add a new Database
AFDatabase newDB = myPISystem.Databases.Add("NewDatabase");
newDB.Description = "This is a new Database";

// Display the Database Count
Console.WriteLine("Database Count = {0}", myPISystem.Databases.Count);
' This example demonstrates how to use several properties of the DB object.

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

' Display information about the Default DB
Console.WriteLine("Name of Default DB = {0}", myDB.Name)
Console.WriteLine("Description of Default DB = {0}", myDB.Description)
Console.WriteLine("UniqueID of Default DB = {0}", myDB.UniqueID)

' Set the DB to the First DB
myDB = myPISystem.Databases(0)

' Display the name, description, and PIServerName of the first db
Console.WriteLine("Name of First DB = {0}", myDB.Name)
Console.WriteLine("Description of First DB = {0}", myDB.Description)
Console.WriteLine("UniqueID of First DB = {0}", myDB.UniqueID)

' Add a new Database
Dim newDB As AFDatabase = myPISystem.Databases.Add("NewDatabase")
newDB.Description = "This is a new Database"

' Display the Database Count
Console.WriteLine("Database Count = {0}", myPISystem.Databases.Count)

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