# Class WorkflowScheme OptimaJet.Workflow.SQLite.WorkflowScheme Database object for workflow scheme storage, querying, and tag management operations. Namespace: [OptimaJet.Workflow.SQLite](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/) ```csharp public class WorkflowScheme : DbObject ``` ## Type Hierarchy - [DbObject](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/DbObject-TEntity/) - WorkflowScheme Current type ## Constructors `public WorkflowScheme(string schemaName, int commandTimeout)` Initializes a new instance of [WorkflowScheme](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/WorkflowScheme/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemaName` | `String` | The database schema name. | | `commandTimeout` | `Int32` | The command timeout in seconds. | ## Methods `public Task SelectByCodeAsync(SqliteConnection connection, string code, string tenantId)` Selects a scheme by code, preferring the tenant-specific scheme over the shared one if both exist. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `code` | `String` | The scheme code. | | `tenantId` | `String` | The tenant identifier, or `null` for shared schemes only. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching scheme entity, or `null` if not found. | `public Task SelectByCodeExactAsync(SqliteConnection connection, string code, string tenantId)` Selects a scheme by code in the exact tenant scope without fallback to shared schemes. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `code` | `String` | The scheme code. | | `tenantId` | `String` | The tenant identifier, or `null` for shared schemes only. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching scheme entity, or `null` if not found. | `public override Task UpsertAsync(SqliteConnection connection, SchemeEntity entity, SqliteTransaction transaction = null)` Inserts or updates a scheme entity using an update-then-insert strategy within a transaction. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `entity` | `SchemeEntity` | The scheme entity to upsert. | | `transaction` | `SqliteTransaction` | An optional transaction. If `null`, an internal transaction is created. | ### Returns | Type | Description | | --- | --- | | `Task` | The number of rows affected. | `public Task SelectAllWorkflowSchemesWithPagingAsync(SqliteConnection connection, List<(string parameterName, SortDirection sortDirection)> orderParameters, Paging paging)` Selects all workflow schemes with optional sorting and paging. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `orderParameters` | `List` | The sorting parameters. | | `paging` | `Paging` | The paging settings, or `null` to return all schemes. | ### Returns | Type | Description | | --- | --- | | `Task` | An array of scheme entities. | `public Task> GetInlinedSchemeCodesAsync(SqliteConnection connection, string tenantId = null)` Returns the distinct codes of schemes that can be inlined into other schemes. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `tenantId` | `String` | The tenant identifier, or `null` for shared schemes. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of inlinable scheme codes. | `public Task> GetRelatedSchemeCodesAsync(SqliteConnection connection, string schemeCode, string tenantId = null)` Returns the codes of schemes that have the specified scheme inlined into them. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `schemeCode` | `String` | The scheme code to search for in inlined scheme references. | | `tenantId` | `String` | The tenant identifier, or `null` for shared schemes. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of related scheme codes. | `public Task> GetSchemeCodesByTagsAsync(SqliteConnection connection, string tenantId, IEnumerable tags)` Returns the codes of schemes matching any of the specified tags within the tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `tenantId` | `String` | The tenant identifier, or `null` for shared schemes. | | `tags` | `IEnumerable` | The tags to match. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of matching scheme codes. | `public Task AddSchemeTagsAsync(SqliteConnection connection, string schemeCode, string tenantId, IEnumerable tags, IWorkflowBuilder builder)` Adds tags to a scheme and updates the scheme definition via the builder. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `schemeCode` | `String` | The scheme code. | | `tenantId` | `String` | The tenant identifier, or `null` for shared schemes. | | `tags` | `IEnumerable` | The tags to add. | | `builder` | `IWorkflowBuilder` | The workflow builder for updating tag references in the scheme definition. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that represents the asynchronous operation. | `public Task RemoveSchemeTagsAsync(SqliteConnection connection, string schemeCode, string tenantId, IEnumerable tags, IWorkflowBuilder builder)` Removes tags from a scheme and updates the scheme definition via the builder. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `schemeCode` | `String` | The scheme code. | | `tenantId` | `String` | The tenant identifier, or `null` for shared schemes. | | `tags` | `IEnumerable` | The tags to remove. | | `builder` | `IWorkflowBuilder` | The workflow builder for updating tag references in the scheme definition. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that represents the asynchronous operation. | `public Task SetSchemeTagsAsync(SqliteConnection connection, string schemeCode, string tenantId, IEnumerable tags, IWorkflowBuilder builder)` Sets the tags on a scheme, replacing all existing tags, and updates the scheme definition via the builder. ### Parameters | Name | Type | Description | | --- | --- | --- | | `connection` | `SqliteConnection` | The SQLite connection. | | `schemeCode` | `String` | The scheme code. | | `tenantId` | `String` | The tenant identifier, or `null` for shared schemes. | | `tags` | `IEnumerable` | The new tags to set. | | `builder` | `IWorkflowBuilder` | The workflow builder for updating tag references in the scheme definition. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that represents the asynchronous operation. | [Previous WorkflowProcessTransitionHistory](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/WorkflowProcessTransitionHistory/) [Next Migration10Initial](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite.Migrations/Migration10Initial/)