Skip to content

PowerShell Transformation Entities

An entity is a generic representation of an object being transformed by a PowerShell transformation script. Each entity contains values that conform to the base connector's schema, including modifications made by preceding adapter transformations.

Entity Object

The entity object is a dictionary (containing a set of name-value pairs). Values can be inserted into the entity through the indexer:

PowerShell
$entity['name'] = 'value';

Values can also be accessed through the indexer:

PowerShell
$value = $entity['name']; # IValue wrapper object 
$value = $entity['name'].Value; # Raw value

Values inserted into an entity may be of any type. The entity attempts to convert each value to the field's schema type. For example:

PowerShell
$entity['Number'] = 1;
$entity['Number'] = '1';
$entity['Number'] = $true;

Values returned by an entity implement the IValue interface. Implementations include:

  • StringValue
  • IntegerValue
  • BooleanValue
  • DateValue
  • MultiValue<StringValue>
  • etc.

Each IValue implementation has a Value property that exposes the underlying .NET value. The following example accesses the raw values of a single-valued string field and a multi-valued integer field:

PowerShell
foreach ($entity in $components.InputEntities) {
  $key = $entity['single-value-key'].Value;          # Raw .NET string
  $values = $entity['multi-value'].Value;            # List of IntegerValue
  $count = 0
  $values | ForEach-Object { $count += $_.Value }    # Sum raw .NET integer values
}

Schema

The accepted values of an entity are defined by the schema of the adapter's base connector, modified by any preceding transformations, and the addition of any new schema fields defined in the PowerShell transformation schema script.