Show / Hide Table of Contents

Interface IDatabaseTableAgent

Interface for the DatabaseTable Agent Agent used for CRUD operations on database tables. Read, add, update, delete rows in tables.

Namespace: SuperOffice.CRM.Services
Assembly: SuperOffice.Services.dll
Syntax
[Agent("DatabaseTable Agent", "Interface for the DatabaseTable Agent. Agent used for CRUD operations on database tables. Read, add, update, delete rows in tables.")]
public interface IDatabaseTableAgent : IAgent
Examples
using SuperOffice;
using SuperOffice.CRM.Services;

using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
   using (DatabaseTableAgent agent = new DatabaseTableAgent())
   {
      // call methods on agent here...
   }
}

Methods

DeleteAsync(string, int[], CancellationToken)

Delete rows, by primary key; traveltransactionlog and WebHooks are supported

Declaration
Task<MassOperationResult> DeleteAsync(string tableName, int[] iDs, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName

The name of the table where rows should be deleted

int[] iDs

Primary keys of the rows to be deleted

CancellationToken cancellationToken
Returns
Type Description
Task<MassOperationResult>

Summary of results

DeleteRowAsync(string, int, CancellationToken)

Delete a row from a table

Declaration
Task DeleteRowAsync(string tableName, int id, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName

The name of the table to delete from; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable

int id

The id of the row to delete

CancellationToken cancellationToken
Returns
Type Description
Task

InsertAsync(string, string[], string[][], CancellationToken)

Mass-insert rows, with or without primary keys specified. Works on physical tables with no special processing for udef etc.; traveltransactionlog and WebHooks are supported

Declaration
Task<MassOperationResult> InsertAsync(string tableName, string[] columns, string[][] data, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName

The name of the table where rows should be inserted

string[] columns

List of column names, in the same order as in the Data parameter

string[][] data

Outer array = rows, inner = columns in specified order; use CultureDataFormatter to format values that aren't string or int

CancellationToken cancellationToken
Returns
Type Description
Task<MassOperationResult>

Summary of results

InsertRowAsync(string, StringDictionary, CancellationToken)

Insert a row into a table

Declaration
Task<int> InsertRowAsync(string tableName, StringDictionary values, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName

The name of the table to insert into; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable

StringDictionary values

A StringDictionary with the values to insert. You do not need to specify all the values in the table. The omitted ones will get default values

CancellationToken cancellationToken
Returns
Type Description
Task<int>

The id of the newly inserted row

ReadRowAsync(string, int, CancellationToken)

Read a row from a table

Declaration
Task<TableRecord> ReadRowAsync(string tableName, int id, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName

The name of the table to fetch; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable

int id

The id of the row to fetch

CancellationToken cancellationToken
Returns
Type Description
Task<TableRecord>

The row from the table

TruncateAsync(string, CancellationToken)

Drop all rows in a table. This clearance is not individually logged in TravelTransactionlog or Webhook/script calls

Declaration
Task<MassOperationResult> TruncateAsync(string tableName, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName

Name of table to be truncated

CancellationToken cancellationToken
Returns
Type Description
Task<MassOperationResult>

Summary of results

UpdateRowAsync(string, int, StringDictionary, CancellationToken)

Update a row in a table

Declaration
Task UpdateRowAsync(string tableName, int id, StringDictionary values, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName

The name of the table to update; in the current release this must be an 'extratable'. Use the database name, on the form y_aTable

int id

The id of the row to update

StringDictionary values

A StringDictionary with the values to update. You do not need to specify all the values in the table. The omitted ones will remain unchanged

CancellationToken cancellationToken
Returns
Type Description
Task

UpsertAsync(string, string[], string[], string[][], UpsertNomatchAction, bool, CancellationToken)

Insert or update rows, optionally deleting/zeroing 'leftover' rows. Special support for UDEF, as well as optional extensive information return. Traveltransactionlog and WebHooks are supported

Declaration
Task<MassOperationResult> UpsertAsync(string tableName, string[] columns, string[] keys, string[][] data, UpsertNomatchAction nomatchAction, bool returnRowStatus, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string tableName

The name of the table where rows should be inserted or updated

string[] columns

List of column names, in the same order as in the data

string[] keys

List of columns that are to be used as keys, to match any existing rows

string[][] data

Outer array = row, inner = column in specified order; use CultureDataFormatter to format values

UpsertNomatchAction nomatchAction

Action to take on rows in the target table, that are not matched by any rows in the incoming data. Use the deletion options with care. NEVER use deletion if your Upsert is so large you need to divide it into multiple batches.

bool returnRowStatus

If true, then the 'RowStatus' member of the return carrier will be populated with a per-row status, for each incoming row

CancellationToken cancellationToken
Returns
Type Description
Task<MassOperationResult>

Summary of results

© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top