Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Overview

Adds or updates rows in DataTable and DataTableDictionary by specified key and properties .

any DataTableDictionary.Ensure(key: string, input: object)

Updates or creates a row with given input properties. If key does not exists initializes new row with initInput properties.

any DataTableDictionary.Ensure(key: string, input: object, initInput: object)

Arguments

string key
Required. Key of rows to be updated or added.
object input
Row properties to be updated.
object initInput
Row properties to be updated if no match found.

Remarks

This method inserts or updates rows in DataTable.

Example

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

var list = table.ToDictionary('Name');

var myGroup = list.Ensure("MyGroup", {
    Name : 'MyGroup',
    Code : '123'
}, {
    Id : Script.NewId()
});

list.Save();

Remarks

This method inserts or updates rows in DataTable.

Example

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

var list = table.ToDictionary('Name');

var myGroup = list.Ensure("MyGroup", {
    Name : 'MyGroup',
    Code : '123'
}, {
    Id : Script.NewId()
});

list.Save();

Examples

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

var list = table.ToDictionary('Name');

var myGroup = list.Ensure("MyGroup", {
    Name : 'MyGroup',
    Code : '123'
}, {
    Id : Script.NewId()
});

list.Save();
  • No labels