Skip to content

Get

Looks up the rows with the specified key.

1
myDataTableDictionary.Get(key: string):( DataRow | Array<DataRow> )

Parameters

string key
    The key to look up.

Returns

The matching DataRow, an array of rows when several rows have the key, or null when no row has the key.

Examples

Look up rows by key instead of querying in a loop

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
var products = $Database.Get({
    TargetSchema : 'Sales',
    TargetTable : 'Products'
}).ToDictionary('Code');

$Xml.SelectAll('Lines/Line', function (line) {
    // Code is unique, so Get returns a single row or null
    var product = products.Get(line.Evaluate('ProductCode'));

    if (product) {
        line.SetValue('Price', product['Price']);
    }
});

See Also