> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SuperOffice.WebApi.Agents.DatabaseTableAgent

# \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent">\</a> Class DatabaseTableAgent

Namespace: [SuperOffice.WebApi.Agents](SuperOffice.WebApi.Agents.md)\
Assembly: SuperOffice.WebApi.dll

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

```csharp theme={null}
public class DatabaseTableAgent : AgentBase, IDatabaseTableAgent, IAgentBase, IDisposable
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ←
[AgentBase](SuperOffice.WebApi.Agents.AgentBase.md) ←
[DatabaseTableAgent](SuperOffice.WebApi.Agents.DatabaseTableAgent.md)

#### Implements

[IDatabaseTableAgent](SuperOffice.WebApi.Agents.IDatabaseTableAgent.md),
[IAgentBase](SuperOffice.WebApi.Agents.IAgentBase.md),
[IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

#### Inherited Members

[AgentBase.\_json](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase__json),
[AgentBase.\_binary](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase__binary),
[AgentBase.\_config](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase__config),
[AgentBase.\_client](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase__client),
[AgentBase.\_disposeClient](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase__disposeClient),
[AgentBase.Merge(RequestOptions)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_Merge_SuperOffice_WebApi_RequestOptions_),
[AgentBase.BuildRequestFromObject(HttpMethod, string, object, WebApiOptions, string)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_BuildRequestFromObject_System_Net_Http_HttpMethod_System_String_System_Object_SuperOffice_WebApi_WebApiOptions_System_String_),
[AgentBase.BuildRequestFromStream(HttpMethod, string, Stream, WebApiOptions, string)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_BuildRequestFromStream_System_Net_Http_HttpMethod_System_String_System_IO_Stream_SuperOffice_WebApi_WebApiOptions_System_String_),
[AgentBase.BuildRequestFromObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_BuildRequestFromObjectWithStream_System_Net_Http_HttpMethod_System_String_System_Object_System_IO_Stream_SuperOffice_WebApi_WebApiOptions_System_String_),
[AgentBase.ParseAuthorization(IAuthorization)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_ParseAuthorization_SuperOffice_WebApi_Authorization_IAuthorization_),
[AgentBase.CancelRequest()](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_CancelRequest),
[AgentBase.SendRequestObject(HttpMethod, string, object, WebApiOptions, string)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_SendRequestObject_System_Net_Http_HttpMethod_System_String_System_Object_SuperOffice_WebApi_WebApiOptions_System_String_),
[AgentBase.SendRequestObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_SendRequestObjectWithStream_System_Net_Http_HttpMethod_System_String_System_Object_System_IO_Stream_SuperOffice_WebApi_WebApiOptions_System_String_),
[AgentBase.SendRequest(HttpRequestMessage, RequestOptions)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_SendRequest_System_Net_Http_HttpRequestMessage_SuperOffice_WebApi_RequestOptions_),
[AgentBase.ThrowOnResponseErrorAsync(HttpRequestMessage, HttpResponseMessage)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_ThrowOnResponseErrorAsync_System_Net_Http_HttpRequestMessage_System_Net_Http_HttpResponseMessage_),
[AgentBase.ParseResponse\<T\&gt;(HttpResponseMessage)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_ParseResponse__1_System_Net_Http_HttpResponseMessage_),
[AgentBase.Finally(RequestOptions)](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_Finally_SuperOffice_WebApi_RequestOptions_),
[AgentBase.Dispose()](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_Dispose),
[AgentBase.Configuration](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_Configuration),
[AgentBase.Client](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_Client),
[AgentBase.HasRunningRequest](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_HasRunningRequest),
[AgentBase.ClientCancellationTokenSource](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_ClientCancellationTokenSource),
[AgentBase.ProgressListener](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_ProgressListener),
[AgentBase.UploadProgressListener](SuperOffice.WebApi.Agents.AgentBase.md#SuperOffice_WebApi_Agents_AgentBase_UploadProgressListener),
[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring),
[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)),
[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)),
[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals),
[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode),
[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype),
[object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone)

## Examples

\<pre>\<code class="lang-csharp">using SuperOffice.WebApi;
using SuperOffice.WebApi.Agents;

var mySession = new WebApiOptions("[http://example.com/super/api](http://example.com/super/api)");
mySession.Authorization = new AuthorizationUsernamePassword("user", "pass");
using (DatabaseTableAgent agent = new DatabaseTableAgent(mySession))
\{
// call methods on agent here...
}\</code>\</pre>

## Constructors

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_\_ctor\_System\_Net\_Http\_HttpClient\_">\</a> DatabaseTableAgent(HttpClient)

Constructor: Agent used for CRUD operations on database tables. Read, add, update, delete rows in tables.

```csharp theme={null}
public DatabaseTableAgent(HttpClient httpClient)
```

#### Parameters

`httpClient` [HttpClient](https://learn.microsoft.com/dotnet/api/system.net.http.httpclient)

Use this HTTP client instead of making own HttpClient instance.

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_\_ctor\_SuperOffice\_WebApi\_WebApiOptions\_System\_Net\_Http\_HttpClient\_">\</a> DatabaseTableAgent(WebApiOptions, HttpClient)

Constructor: Agent used for CRUD operations on database tables. Read, add, update, delete rows in tables.

```csharp theme={null}
public DatabaseTableAgent(WebApiOptions options, HttpClient httpClient = null)
```

#### Parameters

`options` [WebApiOptions](SuperOffice.WebApi.WebApiOptions.md)

Base URL and authentication values.

`httpClient` [HttpClient](https://learn.microsoft.com/dotnet/api/system.net.http.httpclient)

Optional: Use this HTTP client instead of making a new one.

## Methods

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_DeleteAsync\_System\_String\_System\_Int32\_\_\_SuperOffice\_WebApi\_RequestOptions\_">\</a> DeleteAsync(string, int\[], RequestOptions)

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

```csharp theme={null}
public Task<MassOperationResult> DeleteAsync(string tableName, int[] iDs, RequestOptions requestOptions = null)
```

#### Parameters

`tableName` [string](https://learn.microsoft.com/dotnet/api/system.string)

The name of the table where rows should be deleted

`iDs` [int](https://learn.microsoft.com/dotnet/api/system.int32)\[]

Primary keys of the rows to be deleted

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[MassOperationResult](SuperOffice.WebApi.Data.MassOperationResult.md)\&gt;

Summary of results

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_DeleteRowAsync\_System\_String\_System\_Int32\_SuperOffice\_WebApi\_RequestOptions\_">\</a> DeleteRowAsync(string, int, RequestOptions)

Delete a row from a table

```csharp theme={null}
public Task DeleteRowAsync(string tableName, int id, RequestOptions requestOptions = null)
```

#### Parameters

`tableName` [string](https://learn.microsoft.com/dotnet/api/system.string)

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

`id` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The id of the row to delete

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task)

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_InsertAsync\_System\_String\_System\_String\_\_\_System\_String\_\_\_\_\_SuperOffice\_WebApi\_RequestOptions\_">\</a> InsertAsync(string, string\[], string\[]\[], RequestOptions)

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

```csharp theme={null}
public Task<MassOperationResult> InsertAsync(string tableName, string[] columns, string[][] data, RequestOptions requestOptions = null)
```

#### Parameters

`tableName` [string](https://learn.microsoft.com/dotnet/api/system.string)

The name of the table where rows should be inserted

`columns` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]

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

`data` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]\[]

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

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[MassOperationResult](SuperOffice.WebApi.Data.MassOperationResult.md)\&gt;

Summary of results

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_InsertRowAsync\_System\_String\_SuperOffice\_WebApi\_Data\_StringDictionary\_SuperOffice\_WebApi\_RequestOptions\_">\</a> InsertRowAsync(string, StringDictionary, RequestOptions)

Insert a row into a table

```csharp theme={null}
public Task<int> InsertRowAsync(string tableName, StringDictionary values, RequestOptions requestOptions = null)
```

#### Parameters

`tableName` [string](https://learn.microsoft.com/dotnet/api/system.string)

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

`values` [StringDictionary](SuperOffice.WebApi.Data.StringDictionary.md)

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

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[int](https://learn.microsoft.com/dotnet/api/system.int32)\&gt;

The id of the newly inserted row

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_ReadRowAsync\_System\_String\_System\_Int32\_SuperOffice\_WebApi\_RequestOptions\_">\</a> ReadRowAsync(string, int, RequestOptions)

Read a row from a table

```csharp theme={null}
public Task<TableRecord> ReadRowAsync(string tableName, int id, RequestOptions requestOptions = null)
```

#### Parameters

`tableName` [string](https://learn.microsoft.com/dotnet/api/system.string)

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

`id` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The id of the row to fetch

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[TableRecord](SuperOffice.WebApi.Data.TableRecord.md)\&gt;

The row from the table

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_TruncateAsync\_System\_String\_SuperOffice\_WebApi\_RequestOptions\_">\</a> TruncateAsync(string, RequestOptions)

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

```csharp theme={null}
public Task<MassOperationResult> TruncateAsync(string tableName, RequestOptions requestOptions = null)
```

#### Parameters

`tableName` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of table to be truncated

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[MassOperationResult](SuperOffice.WebApi.Data.MassOperationResult.md)\&gt;

Summary of results

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_UpdateRowAsync\_System\_String\_System\_Int32\_SuperOffice\_WebApi\_Data\_StringDictionary\_SuperOffice\_WebApi\_RequestOptions\_">\</a> UpdateRowAsync(string, int, StringDictionary, RequestOptions)

Update a row in a table

```csharp theme={null}
public Task UpdateRowAsync(string tableName, int id, StringDictionary values, RequestOptions requestOptions = null)
```

#### Parameters

`tableName` [string](https://learn.microsoft.com/dotnet/api/system.string)

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

`id` [int](https://learn.microsoft.com/dotnet/api/system.int32)

The id of the row to update

`values` [StringDictionary](SuperOffice.WebApi.Data.StringDictionary.md)

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

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task)

### \<a id="SuperOffice\_WebApi\_Agents\_DatabaseTableAgent\_UpsertAsync\_System\_String\_System\_String\_\_\_System\_String\_\_\_System\_String\_\_\_\_\_SuperOffice\_WebApi\_Data\_UpsertNomatchAction\_System\_Boolean\_SuperOffice\_WebApi\_RequestOptions\_">\</a> UpsertAsync(string, string\[], string\[], string\[]\[], UpsertNomatchAction, bool, RequestOptions)

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

```csharp theme={null}
public Task<MassOperationResult> UpsertAsync(string tableName, string[] columns, string[] keys, string[][] data, UpsertNomatchAction nomatchAction, bool returnRowStatus, RequestOptions requestOptions = null)
```

#### Parameters

`tableName` [string](https://learn.microsoft.com/dotnet/api/system.string)

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

`columns` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]

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

`keys` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]

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

`data` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]\[]

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

`nomatchAction` [UpsertNomatchAction](SuperOffice.WebApi.Data.UpsertNomatchAction.md)

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.

`returnRowStatus` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

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

`requestOptions` [RequestOptions](SuperOffice.WebApi.RequestOptions.md)

Override language/culture codes on this request.

#### Returns

[Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1)\<[MassOperationResult](SuperOffice.WebApi.Data.MassOperationResult.md)\&gt;

Summary of results


## Related topics

- [SuperOffice.WebApi.Agents.CustomObjectAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.CustomObjectAgent.md)
- [SuperOffice.WebApi.Data.TableRecord](/en/api/reference/webapi/SuperOffice.WebApi.Data.TableRecord.md)
- [SuperOffice.WebApi.Agents.ICustomObjectAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.ICustomObjectAgent.md)
- [SuperOffice.WebApi.Data.UpsertRowStatus](/en/api/reference/webapi/SuperOffice.WebApi.Data.UpsertRowStatus.md)
- [SuperOffice.WebApi.Data.MassOperationResult](/en/api/reference/webapi/SuperOffice.WebApi.Data.MassOperationResult.md)
- [SuperOffice.WebApi.Agents.AgentBase](/en/api/reference/webapi/SuperOffice.WebApi.Agents.AgentBase.md)
