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
Delete(String, Int32[])
Delete rows, by primary key; traveltransactionlog and WebHooks are supported
Declaration
MassOperationResult Delete(string tableName, int[] iDs)
Parameters
Type | Name | Description |
---|---|---|
String | tableName | The name of the table where rows should be deleted |
Int32[] | iDs | Primary keys of the rows to be deleted |
Returns
Type | Description |
---|---|
MassOperationResult | Summary of results |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (DatabaseTableAgent agent = new DatabaseTableAgent())
{
// call methods on agent here...
}
}
DeleteRow(String, Int32)
Delete a row from a table
Declaration
void DeleteRow(string tableName, int id)
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 |
Int32 | id | The id of the row to delete |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (DatabaseTableAgent agent = new DatabaseTableAgent())
{
// call methods on agent here...
}
}
Insert(String, String[], String[][])
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
MassOperationResult Insert(string tableName, string[] columns, string[][] data)
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 |
Returns
Type | Description |
---|---|
MassOperationResult | Summary of results |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (DatabaseTableAgent agent = new DatabaseTableAgent())
{
// call methods on agent here...
}
}
InsertRow(String, StringDictionary)
Insert a row into a table
Declaration
int InsertRow(string tableName, StringDictionary values)
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 |
Returns
Type | Description |
---|---|
Int32 | The id of the newly inserted row |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (DatabaseTableAgent agent = new DatabaseTableAgent())
{
// call methods on agent here...
}
}
ReadRow(String, Int32)
Read a row from a table
Declaration
TableRecord ReadRow(string tableName, int id)
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 |
Int32 | id | The id of the row to fetch |
Returns
Type | Description |
---|---|
TableRecord | The row from the table |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (DatabaseTableAgent agent = new DatabaseTableAgent())
{
// call methods on agent here...
}
}
Truncate(String)
Drop all rows in a table. This clearance is not individually logged in TravelTransactionlog or Webhook/script calls
Declaration
MassOperationResult Truncate(string tableName)
Parameters
Type | Name | Description |
---|---|---|
String | tableName | Name of table to be truncated |
Returns
Type | Description |
---|---|
MassOperationResult | Summary of results |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (DatabaseTableAgent agent = new DatabaseTableAgent())
{
// call methods on agent here...
}
}
UpdateRow(String, Int32, StringDictionary)
Update a row in a table
Declaration
void UpdateRow(string tableName, int id, StringDictionary values)
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 |
Int32 | 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 |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (DatabaseTableAgent agent = new DatabaseTableAgent())
{
// call methods on agent here...
}
}
Upsert(String, String[], String[], String[][], UpsertNomatchAction, Boolean)
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
MassOperationResult Upsert(string tableName, string[] columns, string[] keys, string[][] data, UpsertNomatchAction nomatchAction, bool returnRowStatus)
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. |
Boolean | returnRowStatus | If true, then the 'RowStatus' member of the return carrier will be populated with a per-row status, for each incoming row |
Returns
Type | Description |
---|---|
MassOperationResult | Summary of results |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (DatabaseTableAgent agent = new DatabaseTableAgent())
{
// call methods on agent here...
}
}