Introduction

Enzo Server
  Installation
  Quick Start
  Core Features
    Async Calls
    ConnectionStrings
    Edge Cache
    HTTP Access
    Scheduling
    Views
  Advanced Capabilities
    Change Data Capture
  Administration
    Configuration Settings
    Logins & ACL
    Auditing
    Current Executions
    Linked Server
    SSL

  User Guides
     Sharding
     Sharding Overview

     SharePoint

   Adapters
    All Adapters


  SDK
    Overview
    Installation
    DevHost
    Create A Simple Adapter
    Handler Columns

    Advanced SDK Concepts
      Handler Decorators
      Dynamic Columns
      Table & Table Enumerators
      Virtual Tables

/sdk/enumerators




Table & Column Enumerators


In certain cases an adapter will need to implement both Table and Column enumerators. When adapters cannot predict the list of tables/columns from remote systems at design time, it is necessary to provide a dynamic way to return them so that Linked Server can function properly.

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.

You only need to define Table and Column enumerators when you adapters contains handlers that support Handler Decorators and for which the list of returned columns is unknown at design time.

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;
}