Represents a data dictionary from DataTable instance. Dictionary elements are bound to DataTable and any changes from dictionary reflected to DataTable instance.

Dictionaries are used to perform fast searches for big number of data table rows. Search time is always constant time and does not affected from number of rows.

To get a rows from dictionary you can use DataTableDictionary.Get method. If search key matches multiple rows return value is array of data table rows.

You can use DataTableDictionary.Has to check specific key is exists in dictionary or DataTableDictionary.Keys method returns all keys in dictionary as array. 

To add a new row or update if existing you can use DataTableDictionary.Ensure method to ensure specific keys are inserted to database. 


Most common dictionary example is like below;

// Get all rows from database
var table = $Database.Get({
  Parameters : {
    TargetSchema: 'HR',
    TargetTable: 'Groups'
  }
});

// Convert data table to a dictionary based on group name.
var list = table.ToDictionary('Name');
  
// Ensure "MyGroup" is in dictionary.
var myGroup = list.Ensure("MyGroup", {
  // Columns to be updated
  Code : '123'
}, {
  // Columns to be inserted if "MyGroup" is not in dictionary
  Id : Script.NewId()
});
    
// Save dictionary and datatable into database.
list.Save();