# Class WorkflowProcessInstancePersistence OptimaJet.Workflow.SQLite.WorkflowProcessInstancePersistence Database object for workflow process instance persistence parameter operations. Namespace: [OptimaJet.Workflow.SQLite](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/) ```csharp public class WorkflowProcessInstancePersistence : DbObject ``` ## Type Hierarchy - [DbObject](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/DbObject-TEntity/) - WorkflowProcessInstancePersistence Current type ## Constructors `public WorkflowProcessInstancePersistence(string schemaName, int commandTimeout)` Initializes a new instance of [WorkflowProcessInstancePersistence](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/WorkflowProcessInstancePersistence/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemaName` | `String` | The database schema name. | | `commandTimeout` | `Int32` | The command timeout in seconds. | ## Methods `public Task SelectByProcessIdAsync(SqliteConnection connection, Guid processId)` Selects all persistence parameter entities for the specified process. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `processId` | `Guid` | The process identifier. | ### Returns | Type | Description | | --- | --- | | `Task` | An array of persistence parameter entities. | `public Task SelectByNameAsync(SqliteConnection connection, Guid processId, string parameterName)` Selects a single persistence parameter entity by process identifier and parameter name. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `processId` | `Guid` | The process identifier. | | `parameterName` | `String` | The parameter name. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching entity, or `null` if not found. | `public Task DeleteByProcessIdAsync(SqliteConnection connection, Guid processId, SqliteTransaction transaction = null)` Deletes all persistence parameters for the specified process. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `processId` | `Guid` | The process identifier. | | `transaction` | `SqliteTransaction` | An optional transaction. | ### Returns | Type | Description | | --- | --- | | `Task` | The number of rows affected. | `public Task DeleteByNameAsync(SqliteConnection connection, Guid processId, string parameterName, SqliteTransaction transaction = null)` Deletes a single persistence parameter by process identifier and parameter name. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `processId` | `Guid` | The process identifier. | | `parameterName` | `String` | The parameter name. | | `transaction` | `SqliteTransaction` | An optional transaction. | ### Returns | Type | Description | | --- | --- | | `Task` | The number of rows affected. | `public Task UpsertAsync(SqliteConnection connection, ProcessInstancePersistenceEntity entity, bool preferUpdateFirst, SqliteTransaction transaction)` Inserts or updates a persistence parameter, choosing the operation order based on `preferUpdateFirst`. When `preferUpdateFirst` is `true`, attempts UPDATE first with INSERT fallback. Otherwise, attempts INSERT first with UPDATE fallback on duplicate key. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `entity` | `ProcessInstancePersistenceEntity` | The persistence parameter entity to upsert. | | `preferUpdateFirst` | `Boolean` | Whether to attempt UPDATE before INSERT. | | `transaction` | `SqliteTransaction` | The transaction to execute within. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that represents the asynchronous operation. | [Previous WorkflowProcessInstance](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/WorkflowProcessInstance/) [Next WorkflowProcessInstanceStatus](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/WorkflowProcessInstanceStatus/)