# Class DbObject OptimaJet.Workflow.PostgreSQL.DbObject Namespace: [OptimaJet.Workflow.PostgreSQL](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/) ```csharp public class DbObject where TEntity : IEntity, new() ``` ## Type Hierarchy - DbObject Current type - [ProcessInstanceTree](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/ProcessInstanceTree/) - [WorkflowApprovalHistory](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowApprovalHistory/) - [WorkflowForm](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL.Models/WorkflowForm/) - [WorkflowGlobalParameter](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowGlobalParameter/) - [WorkflowInbox](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowInbox/) - [WorkflowProcessInstance](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowProcessInstance/) - [WorkflowProcessInstancePersistence](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowProcessInstancePersistence/) - [WorkflowProcessInstanceStatus](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowProcessInstanceStatus/) - [WorkflowProcessScheme](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowProcessScheme/) - [WorkflowProcessTimer](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowProcessTimer/) - [WorkflowProcessTransitionHistory](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowProcessTransitionHistory/) - [WorkflowRuntime](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL.Models/WorkflowRuntime/) - [WorkflowScheme](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/WorkflowScheme/) - [WorkflowSync](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL.Models/WorkflowSync/) ## Constructors `public DbObject(string schemaName, string dbTableName, int commandTimeout)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemaName` | `String` | | | `dbTableName` | `String` | | | `commandTimeout` | `Int32` | | ## Properties `public int CommandTimeout { get; }` `public string SchemaName { get; }` `public string DbTableName { get; }` `public string ObjectName { get; }` ## Methods `public Task InsertAsync(NpgsqlConnection connection, TEntity entity, NpgsqlTransaction transaction = null)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `entity` | `{TEntity}` | | | `transaction` | `NpgsqlTransaction` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public virtual Task UpsertAsync(NpgsqlConnection connection, TEntity entity, NpgsqlTransaction transaction = null)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `entity` | `{TEntity}` | | | `transaction` | `NpgsqlTransaction` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public virtual Task UpdateAsync(NpgsqlConnection connection, TEntity entity, NpgsqlTransaction transaction = null)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `entity` | `{TEntity}` | | | `transaction` | `NpgsqlTransaction` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SelectAllAsync(NpgsqlConnection connection)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SelectAllWithPagingAsync(NpgsqlConnection connection, List<(string parameterName, SortDirection sortDirection)> orderParameters, Paging paging)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `orderParameters` | `List` | | | `paging` | `Paging` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SelectByKeyAsync(NpgsqlConnection connection, object id)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `id` | `Object` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SelectByAsync(NpgsqlConnection connection, Expression> selectorLambda, TSelect value)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `selectorLambda` | `Expression` | | | `value` | `{TSelect}` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task DeleteByAsync(NpgsqlConnection connection, Expression> selectorLambda, TSelect value, NpgsqlTransaction transaction = null)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `selectorLambda` | `Expression` | | | `value` | `{TSelect}` | | | `transaction` | `NpgsqlTransaction` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SelectByWithPagingAsync(NpgsqlConnection connection, Expression> selectorLambda, TSelect value, Expression> sortLambda, SortDirection sortDirection, Paging paging)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `selectorLambda` | `Expression` | | | `value` | `{TSelect}` | | | `sortLambda` | `Expression` | | | `sortDirection` | `SortDirection` | | | `paging` | `Paging` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task DeleteAsync(NpgsqlConnection connection, object id, NpgsqlTransaction transaction = null)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `id` | `Object` | | | `transaction` | `NpgsqlTransaction` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task GetCountAsync(NpgsqlConnection connection)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task GetCountByAsync(NpgsqlConnection connection, Expression> selectorLambda, TSelect value, NpgsqlTransaction transaction = null)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `selectorLambda` | `Expression` | | | `value` | `{TSelect}` | | | `transaction` | `NpgsqlTransaction` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task ExecuteCommandNonQueryAsync(NpgsqlConnection connection, string commandText, params NpgsqlParameter[] parameters)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `commandText` | `String` | | | `parameters` | `NpgsqlParameter[]` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task ExecuteCommandNonQueryAsync(NpgsqlConnection connection, string commandText, NpgsqlTransaction transaction = null, params NpgsqlParameter[] parameters)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `commandText` | `String` | | | `transaction` | `NpgsqlTransaction` | | | `parameters` | `NpgsqlParameter[]` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task ExecuteCommandScalarAsync(NpgsqlConnection connection, string commandText, params NpgsqlParameter[] parameters)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `commandText` | `String` | | | `parameters` | `NpgsqlParameter[]` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task ExecuteCommandScalarAsync(NpgsqlConnection connection, string commandText, NpgsqlTransaction transaction = null, params NpgsqlParameter[] parameters)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `commandText` | `String` | | | `transaction` | `NpgsqlTransaction` | | | `parameters` | `NpgsqlParameter[]` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SelectAsync(NpgsqlConnection connection, string commandText, params NpgsqlParameter[] parameters)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `commandText` | `String` | | | `parameters` | `NpgsqlParameter[]` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SelectAsync(NpgsqlConnection connection, string commandText, NpgsqlTransaction transaction, params NpgsqlParameter[] parameters)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `commandText` | `String` | | | `transaction` | `NpgsqlTransaction` | | | `parameters` | `NpgsqlParameter[]` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task>> SelectAsDictionaryAsync(NpgsqlConnection connection, string commandText, params NpgsqlParameter[] parameters)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `commandText` | `String` | | | `parameters` | `NpgsqlParameter[]` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task InsertAllAsync(NpgsqlConnection connection, TEntity[] values, NpgsqlTransaction transaction = null)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `NpgsqlConnection` | | | `values` | `{TEntity}[]` | | | `transaction` | `NpgsqlTransaction` | | ### Returns | Type | Description | | --- | --- | | `Task` | | `public NpgsqlParameter CreateParameter(TEntity entity, ColumnInfo column, string namePrefix = "")` ### Parameters | Name | Type | Description | | --- | --- | --- | | `entity` | `{TEntity}` | | | `column` | `ColumnInfo` | | | `namePrefix` | `String` | | ### Returns | Type | Description | | --- | --- | | `NpgsqlParameter` | | `protected static object ToDbValue(TValue value, NpgsqlDbType type)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `value` | `{TValue}` | | | `type` | `NpgsqlDbType` | | ### Returns | Type | Description | | --- | --- | | `Object` | | `protected static object FromDbValue(TValue dbValue, NpgsqlDbType type)` ### Parameters | Name | Type | Description | | --- | --- | --- | | `dbValue` | `{TValue}` | | | `type` | `NpgsqlDbType` | | ### Returns | Type | Description | | --- | --- | | `Object` | | `public string GetKeyOrFirstColumn()` ### Returns | Type | Description | | --- | --- | | `String` | | ## Fields `public static List DBColumnsStatic` `public List DBColumns` [Previous ColumnInfo](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/ColumnInfo/) [Next FileSchemePersistencePostgreSQLProvider](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/FileSchemePersistencePostgreSQLProvider/)