/sdk/enumerators
Table & Column Enumerators
For example a SaaS platform like SharePoint would need to implement both a Table and Column enumerator method since it is not possible to know ahead of time the list of SharePoint lists and fields that are available at design time.
These enumerators are implemented as function methods from the base Adpater class: TableEnumerator and ColumnEnumerator.
Generally speaking enumerators are needed when the list of tables and columns could change at any time, and calls from Linked Server are needed.
Table Enumerator
To implement the Table Enumerator you will need to set the TableEnumerator function method. This method is usually
set inside the RegisterAdapter() method and should return the name of the table requested if it exists, or
all available tables if no name is specified.
Add this snippet to the RegisterAdapter() method:
public override void RegisterAdapter() { TablesEnumerator = enumerateTables; // ... register handlers }
private EventResult enumerateTables(object sender, ExecEventArgs e, string tableName, TableList tables) { EventResult retval = new EventResult(e); try { if (!string.IsNullOrEmpty(tableName)) // request for a specific table bane { // does table exist? bool exists = true; // add logic to determine if a table actually exists in remote system if (exists) tables.Add(tableName); // yes - table does exist, so add it to the tables collection } else { // list all available tables from remote system... string[] allTables = new string[] { "table1", "table2", "table3" }; foreach (var name in allTables) tables.Add(name); } } catch (Exception ex) { LogWarning(ex, "enumerateTables()"); } return retval; }
Column Enumerator
When a Table enumerator has been defined, it is usually necessary to declare a Column enumerator. The purpose
of this method is to return all available columns for a given table.
Add this snippet to the RegisterAdapter() method:
public override void RegisterAdapter() { ColumnEnumerator = enumerateColumns; // ... register handlers }
private EventResult enumerateColumns(object sender, ExecEventArgs e, string tableName, ColumnList columns) { EventResult retval = new EventResult(e); // Get columns from the remote table stored in the tableName argument // You must assign the proper data tables for the columns // Add 3 columns as an example columns.Add(tableName, "PartitionKey"); columns.Add(tableName, "RowKey"); columns.Add(tableName, "Timestamp", "", TypeCode.DateTime); return retval; }