AFDatabase Class
- Last UpdatedNov 18, 2025
- 11 minute read
- PI System
- AF SDK 2024 R2
- Developer

Inheritance Hierarchy
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
| Name | Description | |
|---|---|---|
| Analyses | Obsolete.
Gets the collection of analyses maintained by the
AFDatabase.
| |
| AnalysisCategories |
Gets the collection of analysis categories
maintained by the AFDatabase.
| |
| AnalysisTemplates |
Gets the collection of top-level pre-configured analysis rule template maintained by the
AFDatabase.
| |
| AttributeCategories |
Gets the collection of attribute categories
maintained by the AFDatabase.
| |
| DefaultPIServerName |
This property is the name of the default PIServer for this AFDatabase.
| |
| Description |
Read/write property that provides a more detailed description of the object.
| |
| ElementCategories |
Gets the collection of element categories
maintained by the AFDatabase.
| |
| Elements |
Gets the collection of top-level elements maintained by the
AFDatabase.
| |
| ElementTemplates |
Gets the collection of element templates maintained by the
AFDatabase.
| |
| EnumerationSets |
Gets the collection of enumerations maintained by the AFDatabase.
| |
| ExtendedProperties |
A dictionary of extended properties that can be used to store application specific information.
| |
| HasItemsCheckedOut |
Determines if any items are currently checked out in the AFDatabase.
| |
| HasItemsCheckedOutToMe |
Determines if any items are currently checked out to the current user in the
AFDatabase.
| |
| 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 |
Indicates whether there are objects in the AFDatabase that
have been modified since the last save in to persistent storage.
| |
| ModifyDate |
This read-only property returns the time when any object within the database was last modified.
| |
| Name |
This read/write property is the name that identifies the AFDatabase on the
local machine.
| |
| NotificationRuleCategories |
Gets the collection of analysis categories
maintained by the AFDatabase.
| |
| Notifications | Obsolete.
Gets the collection of top-level notifications maintained by the
AFDatabase.
| |
| PISystem |
This read-only property allows access to the PISystem associated with this
object.
(Inherited from AFObject.) | |
| QueryDate |
This read-only property returns the date used to retrieve the version of an object.
| |
| ReferenceTypeCategories |
Gets the collection of reference type categories
maintained by the AFDatabase.
| |
| ReferenceTypes |
Gets the collection of reference types maintained by
the AFDatabase that can be used when defining relationships between
elements.
| |
| Security |
This read-only property returns the AFSecurity information for the object.
| |
| TableCategories |
Gets the collection of element categories
maintained by the AFDatabase.
| |
| TableConnections |
This property provides access to the table connection collection, which you can use to
access external tables of user-defined information.
| |
| Tables |
This property provides access to the table database, which you can use to
define and/or access tables of user-defined information.
| |
| UniqueID |
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.) |
Methods
| Name | Description | |
|---|---|---|
| AddTransfer(String) |
Creates a new AFTransfer without specifying a template.
| |
| AddTransfer(String, AFElementTemplate) |
Creates a new transfer based upon the specified template.
| |
| 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.
| |
| 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.
| |
| ApplyQueryDate |
Applies the specified query date to the current object and returns an object in the new context.
| |
| 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.
| |
| CheckIn(AFCheckedOutMode) |
This method checks in (commits) all the changes to the objects in the database
according to the specified AFCheckedOutMode.
| |
| CompareTo(Object) |
Compares this instance with a specified Object.
(Inherited from AFObject.) | |
| CompareTo(AFObject) |
Compares this instance with a specified AFObject.
(Inherited from AFObject.) | |
| 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.) | |
| FindChangedItems(Boolean, AFTime, AFTime) | Obsolete.
Find all the items that have changed in the AFDatabase.
| |
| FindChangedItems(Boolean, Int32, Object, Object) |
Find all the items that have changed in the AFDatabase.
| |
| FindChangedItems(AFIdentity, Boolean, AFTime, AFTime) | Obsolete.
Find all the items that have changed in the AFDatabase of the
specified type.
| |
| FindChangedItems(AFIdentity, Boolean, Int32, Object, Object) |
Find all the items that have changed in the AFDatabase of the
specified type.
| |
| FindCheckedOutItems(Boolean) |
This method finds all the items that are currently checked out in the
AFDatabase.
| |
| FindCheckedOutItems(AFCheckedOutMode) |
This method finds the items that are currently checked out in the
AFDatabase according to the specified AFCheckedOutMode.
| |
| 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.) | |
| 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 database since loaded
without discarding unapplied changes.
| |
| Refresh(Boolean) |
Refreshes the client with any changes that have been made to the database since loaded
with an option to discard unapplied changes.
| |
| RemoveTransfer |
Removes an existing AFTransfer from the database.
| |
| ToString |
Returns a String that represents the current object.
(Inherited from AFObject.) | |
| 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
| Name | Description | |
|---|---|---|
| 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.