AFTable.SetExtendedProperty Method
- Last UpdatedNov 18, 2025
- 5 minute read
- PI System
- AF SDK 2024 R2
- Developer
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public void SetExtendedProperty( string colName, string propName, Object propValue )
Public Sub SetExtendedProperty ( colName As String, propName As String, propValue As Object ) Dim instance As AFTable Dim colName As String Dim propName As String Dim propValue As Object instance.SetExtendedProperty(colName, propName, propValue)
public: void SetExtendedProperty( String^ colName, String^ propName, Object^ propValue )
member SetExtendedProperty : colName : string * propName : string * propValue : Object -> unit
Parameters
- colName
- Type: SystemString
The name of the table's column whose extended property is to be updated. If or an empty string, then the extended property of the table is updated. - propName
- Type: SystemString
The name of the extended property to be updated. - propValue
- Type: SystemObject
The new value for the extended property. If the new value is , then the extended property will be deleted.
Remarks
This method can be used to store custom information with the table or a column of the table. This is similar to setting the customized user information directly on the DataTable.ExtendedProperties property.
If a column is renamed, then any extended properties for that column will be lost and will need to be set again. After the rename, you can still use the old column name to remove the old extended properties.
The Table Lookup Data Reference takes advantage of this information to allow the user to configure the time zone and units-of-measure for a column in one place instead of in each instance of the Data Reference. The Table Lookup Data Reference looks for these specific extended properties of a column:
| Property Name | Description |
|---|---|
| TimeZone | Specifies the AFTimeZone.Name of the date values in the column. Defaults to time expressed in coordinated universal time (UTC). See TimeZone for a way to provide a default time zone for the entire table. |
| UOM | Defines the Unit-Of-Measure of values in this column. |
Examples
// This example demonstrates how to import a table using an ADO.NET DataTable to create an // internal table. It also demonstrates setting and getting the extended properties of an AFTable. // Get the Database PISystems myPISystems = new PISystems(); AFDatabase myDB = myPISystems.DefaultPISystem.Databases.DefaultDatabase; // Create a small Table using an ADO.NET DataTable DataTable dtMyTable = new DataTable(); dtMyTable.Locale = CultureInfo.CurrentCulture; AFTable myTable = myDB.Tables.Add("myTable"); myTable.TimeZone = AFTimeZone.UtcTimeZone; myTable.Description = "This is my table."; dtMyTable.Columns.Add("TankName", typeof(System.String)); dtMyTable.Columns.Add("Height", typeof(System.Double)); dtMyTable.Columns.Add("Volume", typeof(System.Double)); dtMyTable.Columns.Add("Date", typeof(System.DateTime)); AFTable.InitializeDataTable(myTable, dtMyTable); DataRow drMyRow0 = dtMyTable.NewRow(); drMyRow0["TankName"] = "TK101"; drMyRow0["Height"] = 0; drMyRow0["Volume"] = 0; drMyRow0["Date"] = DateTime.UtcNow; DataRow drMyRow1 = dtMyTable.NewRow(); drMyRow1["TankName"] = "TK101"; drMyRow1["Height"] = 1; drMyRow1["Volume"] = 12.4; drMyRow1["Date"] = DateTime.UtcNow.AddDays(-1); DataRow drMyRow2 = dtMyTable.NewRow(); drMyRow2["TankName"] = "TK101"; drMyRow2["Height"] = 2; drMyRow2["Volume"] = 48.6; drMyRow2["Date"] = DateTime.UtcNow.AddDays(-2); dtMyTable.Rows.Add(drMyRow0); dtMyTable.Rows.Add(drMyRow1); dtMyTable.Rows.Add(drMyRow2); dtMyTable.AcceptChanges(); // Set the Table and CachInterval Properties // and Set the UOM for Volume myTable.Table = dtMyTable; myTable.CacheInterval = TimeSpan.FromMinutes(10); myTable.SetExtendedProperty("Volume", "UOM", "US gal"); myTable.CheckIn(); // Display the table name and description Console.WriteLine("Table Name = {0}", myTable.Name); Console.WriteLine("Description = {0}", myTable.Description); Console.WriteLine(); // Get the UOM for Volume string uomName = myTable.GetExtendedProperty("Volume", "UOM") as string; if (!String.IsNullOrEmpty(uomName)) { Console.WriteLine("UOM Property = {0}", uomName); Console.WriteLine(); } // Display the DataTable foreach (DataRow row in myTable.Table.Rows) { Console.WriteLine("Tank Name = {0}", row["TankName"]); Console.WriteLine(" Height = {0}", row["Height"]); Console.WriteLine(" Volume = {0}", row["Volume"]); Console.WriteLine(" Date = {0}", row["Date"]); } // The Table can be Refreshed Manually using AFTable.Refresh myTable.Refresh();
' This example demonstrates how to import a table using an ADO.NET DataTable to create an ' internal table. It also demonstrates setting and getting the extended properties of an AFTable. ' Get the Database Dim myPISystems As New PISystems Dim myDB As AFDatabase = myPISystems.DefaultPISystem.Databases.DefaultDatabase ' Create a small Table using an ADO.NET DataTable Dim dtMyTable As New DataTable() dtMyTable.Locale = CultureInfo.CurrentCulture Dim myTable As AFTable = myDB.Tables.Add("myTable") myTable.TimeZone = AFTimeZone.UtcTimeZone myTable.Description = "This is my table." dtMyTable.Columns.Add("TankName", GetType(String)) dtMyTable.Columns.Add("Height", GetType(Double)) dtMyTable.Columns.Add("Volume", GetType(Double)) dtMyTable.Columns.Add("Date", GetType(DateTime)) Dim drMyRow0 As DataRow = dtMyTable.NewRow() drMyRow0.Item("TankName") = "TK101" drMyRow0.Item("Height") = 0.0# drMyRow0.Item("Volume") = 0.0# drMyRow0.Item("Date") = DateTime.UtcNow Dim drMyRow1 As DataRow = dtMyTable.NewRow() drMyRow1.Item("TankName") = "TK101" drMyRow1.Item("Height") = 1.0# drMyRow1.Item("Volume") = 12.4 drMyRow1.Item("Date") = DateTime.UtcNow.AddDays(-1) Dim drMyRow2 As DataRow = dtMyTable.NewRow() drMyRow2.Item("TankName") = "TK101" drMyRow2.Item("Height") = 2.0# drMyRow2.Item("Volume") = 48.6 drMyRow2.Item("Date") = DateTime.UtcNow.AddDays(-2) dtMyTable.Rows.Add(drMyRow0) dtMyTable.Rows.Add(drMyRow1) dtMyTable.Rows.Add(drMyRow2) dtMyTable.AcceptChanges() ' Set the Table and CachInterval Properties ' and Set the UOM for Volume myTable.Table = dtMyTable myTable.CacheInterval = TimeSpan.FromMinutes(10) myTable.SetExtendedProperty("Volume", "UOM", "US gal") myTable.CheckIn() ' Display the table name and description Console.WriteLine("Table Name = {0}", myTable.Name) Console.WriteLine("Description = {0}", myTable.Description) Console.WriteLine() ' Get the UOM for Volume Dim uomName As String = TryCast(myTable.GetExtendedProperty("Volume", "UOM"), String) If Not String.IsNullOrEmpty(uomName) Then Console.WriteLine("UOM Property = {0}", uomName) Console.WriteLine() End If ' Display the DataTable For Each row As DataRow In myTable.Table.Rows Console.WriteLine("Tank Name = {0}", row("TankName")) Console.WriteLine(" Height = {0}", row("Height")) Console.WriteLine(" Volume = {0}", row("Volume")) Console.WriteLine(" Date = {0}", row("Date")) Next ' The Table can be Refreshed Manually using AFTable.Refresh myTable.Refresh()
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.