# Interface ISchemePersistenceProvider OptimaJet.Workflow.Core.Persistence.ISchemePersistenceProvider Defines asynchronous persistence operations for unparsed source schemes, stored built scheme versions, Scheme Inlining relationships, and scheme tags. Namespace: [OptimaJet.Workflow.Core.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/) ```csharp public interface ISchemePersistenceProvider where TSchemeMedium : class ``` ## Type Hierarchy - ISchemePersistenceProvider Current type - Derived interfaces - [IWorkflowProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/IWorkflowProvider/) - Implementing types - [MongoDBProvider](https://api.workflowengine.io/mongodb/OptimaJet.Workflow.MongoDB/MongoDBProvider/) - [MSSQLProvider](https://api.workflowengine.io/sql-server/OptimaJet.Workflow.DbPersistence/MSSQLProvider/) - [FileSchemePersistenceMSSQLProvider](https://api.workflowengine.io/sql-server/OptimaJet.Workflow.DbPersistence/FileSchemePersistenceMSSQLProvider/) - [MySQLProvider](https://api.workflowengine.io/mysql/OptimaJet.Workflow.MySQL/MySQLProvider/) - [OracleProvider](https://api.workflowengine.io/oracle/OptimaJet.Workflow.Oracle/OracleProvider/) - [FileSchemePersistenceOracleProvider](https://api.workflowengine.io/oracle/OptimaJet.Workflow.Oracle/FileSchemePersistenceOracleProvider/) - [PostgreSQLProvider](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/PostgreSQLProvider/) - [FileSchemePersistencePostgreSQLProvider](https://api.workflowengine.io/postgresql/OptimaJet.Workflow.PostgreSQL/FileSchemePersistencePostgreSQLProvider/) - [SqliteProvider](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/SqliteProvider/) - [FileSchemePersistenceSqliteProvider](https://api.workflowengine.io/sqlite/OptimaJet.Workflow.SQLite/FileSchemePersistenceSqliteProvider/) ## Methods `Task> GetProcessSchemeByProcessIdAsync(Guid processId)` Gets the stored built scheme version assigned to a process instance. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The identifier of the process instance whose assigned scheme is retrieved. | ### Returns | Type | Description | | --- | --- | | `Task>` | The [SchemeDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/SchemeDefinition-T/) assigned to the process instance. | ### Exceptions | Type | Description | | --- | --- | | `ProcessNotFoundException` | Thrown when no process instance exists with `processId`. | | `SchemeNotFoundException` | Thrown when the process instance has no assigned scheme or its stored built scheme version cannot be found. | `Task> GetProcessSchemeBySchemeIdAsync(Guid schemeId)` Gets a stored built scheme version by its scheme ID. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeId` | `Guid` | The scheme ID of the stored built scheme version. | ### Returns | Type | Description | | --- | --- | | `Task>` | The requested [SchemeDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/SchemeDefinition-T/). | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no stored built scheme version exists with `schemeId`. | `Task> GetProcessSchemeWithParametersAsync(string schemeCode, Guid? rootSchemeId, bool ignoreObsolete, string? tenantId = null)` Gets a stored built scheme version that matches a scheme code, root scheme ID, obsolete-version filter, and tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the stored built scheme version to retrieve. | | `rootSchemeId` | `Nullable` | The root scheme ID for a subprocess scheme, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to select versions without a root scheme. | | `ignoreObsolete` | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to exclude obsolete versions; [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to include obsolete and non-obsolete versions. | | `tenantId` | `String` | The tenant identifier that defines the exact search scope, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to search shared schemes. | ### Returns | Type | Description | | --- | --- | | `Task>` | The matching [SchemeDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/SchemeDefinition-T/). | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no stored built scheme version matches the supplied criteria. | `Task GetSchemeAsync(string code, string? tenantId = null)` Gets the unparsed source scheme identified by a scheme code. ### Parameters | Name | Type | Description | | --- | --- | --- | | `code` | `String` | The code of the source scheme to retrieve. | | `tenantId` | `String` | The tenant identifier used to prefer a tenant-specific scheme over a shared scheme, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to search only shared schemes. | ### Returns | Type | Description | | --- | --- | | `Task` | The unparsed source scheme represented by `TSchemeMedium`. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no source scheme with `code` is available in the requested scope. | `Task> SaveSchemeAsync(SchemeDefinition scheme)` Stores a built scheme version if no matching version is already persisted. ### Parameters | Name | Type | Description | | --- | --- | --- | | `scheme` | `SchemeDefinition` | The [SchemeDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/SchemeDefinition-T/) containing the built scheme and stored-version metadata to persist. | ### Returns | Type | Description | | --- | --- | | `Task>` | The stored [SchemeDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/SchemeDefinition-T/), either newly inserted or an existing matching version. | `Task UpsertSchemeAsync(SchemeDefinition scheme)` Inserts or updates a stored built scheme version. ### Parameters | Name | Type | Description | | --- | --- | --- | | `scheme` | `SchemeDefinition` | The [SchemeDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/SchemeDefinition-T/) containing the built scheme and stored-version metadata to insert or update. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | `Task SetSchemeIsObsoleteAsync(string schemeCode, string? tenantId = null)` Marks stored built scheme versions associated with a scheme code as obsolete. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The scheme code whose stored built versions are marked obsolete. | | `tenantId` | `String` | The tenant identifier to target, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to target matching versions in every tenant scope. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | `Task SaveSchemeAsync(string schemeCode, bool canBeInlined, List inlinedSchemes, string scheme, List tags, string? tenantId = null)` Saves an unparsed source scheme together with its Scheme Inlining relationships and tags. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code under which the source scheme is stored. | | `canBeInlined` | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the scheme can be inlined into another scheme; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | | `inlinedSchemes` | `List` | The codes of the inlinable schemes referenced by this scheme. | | `scheme` | `String` | The serialized unparsed source scheme. | | `tags` | `List` | The scheme tags to store. | | `tenantId` | `String` | The tenant identifier that defines the exact storage scope, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for a shared scheme. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | `Task> GetInlinedSchemeCodesAsync(string? tenantId = null)` Gets the distinct codes of schemes available for use as inlinable schemes. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tenantId` | `String` | The tenant identifier. When specified, the result includes shared schemes and schemes in that tenant scope; when [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), the result includes only shared schemes. | ### Returns | Type | Description | | --- | --- | | `Task` | The distinct inlinable scheme codes. | `Task> GetRelatedByInliningSchemeCodesAsync(string schemeCode, string? tenantId = null)` Gets the distinct codes of schemes that inline the specified scheme. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the inlinable scheme. | | `tenantId` | `String` | The tenant identifier of the parent schemes to search. When specified, only that tenant scope is searched; when [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), shared schemes and all tenant scopes are searched. | ### Returns | Type | Description | | --- | --- | | `Task` | The distinct codes of schemes that inline the specified scheme. | `Task> SearchSchemesByTagsAsync(params string[] tags)` Gets the codes of shared schemes that match at least one specified tag. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tags` | `String[]` | The tags to match. If the array is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty, all shared scheme codes are returned. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching shared scheme codes. | `Task> SearchSchemesByTagsAsync(IEnumerable? tags)` Gets the codes of shared schemes that match at least one specified tag. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tags` | `IEnumerable` | The tags to match, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to return all shared scheme codes. An empty collection also returns all shared scheme codes. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching shared scheme codes. | `Task> SearchSchemesByTagsAsync(string? tenantId, IEnumerable? tags)` Gets the codes of schemes in an exact tenant scope that match at least one specified tag. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tenantId` | `String` | The tenant identifier that defines the exact search scope, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to search shared schemes. | | `tags` | `IEnumerable` | The tags to match, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to return every scheme code in the selected scope. An empty collection also returns every scheme code in that scope. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching scheme codes in the selected scope. | `Task> SearchSchemesByTagsInTenantAsync(string tenantId, params string[] tags)` Gets the codes of schemes in a specified tenant that match at least one specified tag. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tenantId` | `String` | The tenant identifier that defines the exact search scope. | | `tags` | `String[]` | The tags to match. If the array is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) or empty, every scheme code in the tenant scope is returned. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching scheme codes in the specified tenant. | `Task AddSchemeTagsAsync(string schemeCode, params string[] tags)` Adds tags to a source scheme in the shared scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the shared source scheme. | | `tags` | `String[]` | The scheme tags to add. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when the shared source scheme identified by `schemeCode` does not exist. | `Task AddSchemeTagsAsync(string schemeCode, IEnumerable tags)` Adds tags to a source scheme in the shared scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the shared source scheme. | | `tags` | `IEnumerable` | The scheme tags to add. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when the shared source scheme identified by `schemeCode` does not exist. | `Task AddSchemeTagsAsync(string schemeCode, string? tenantId, IEnumerable tags)` Adds tags to a source scheme in an exact tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The source scheme code. | | `tenantId` | `String` | The tenant identifier that defines the exact scope, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for the shared scope. | | `tags` | `IEnumerable` | The scheme tags to add. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no source scheme with `schemeCode` exists in the scope selected by `tenantId`. | `Task AddSchemeTagsInTenantAsync(string schemeCode, string tenantId, params string[] tags)` Adds tags to a source scheme in a specified tenant. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The source scheme code. | | `tenantId` | `String` | The tenant identifier that defines the exact scope. | | `tags` | `String[]` | The scheme tags to add. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no source scheme with `schemeCode` exists in the scope selected by `tenantId`. | `Task RemoveSchemeTagsAsync(string schemeCode, params string[] tags)` Removes tags from a source scheme in the shared scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the shared source scheme. | | `tags` | `String[]` | The scheme tags to remove. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when the shared source scheme identified by `schemeCode` does not exist. | `Task RemoveSchemeTagsAsync(string schemeCode, IEnumerable tags)` Removes tags from a source scheme in the shared scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the shared source scheme. | | `tags` | `IEnumerable` | The scheme tags to remove. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when the shared source scheme identified by `schemeCode` does not exist. | `Task RemoveSchemeTagsAsync(string schemeCode, string? tenantId, IEnumerable tags)` Removes tags from a source scheme in an exact tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The source scheme code. | | `tenantId` | `String` | The tenant identifier that defines the exact scope, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for the shared scope. | | `tags` | `IEnumerable` | The scheme tags to remove. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no source scheme with `schemeCode` exists in the scope selected by `tenantId`. | `Task RemoveSchemeTagsInTenantAsync(string schemeCode, string tenantId, params string[] tags)` Removes tags from a source scheme in a specified tenant. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The source scheme code. | | `tenantId` | `String` | The tenant identifier that defines the exact scope. | | `tags` | `String[]` | The scheme tags to remove. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no source scheme with `schemeCode` exists in the scope selected by `tenantId`. | `Task SetSchemeTagsAsync(string schemeCode, IEnumerable tags)` Replaces all tags on a source scheme in the shared scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the shared source scheme. | | `tags` | `IEnumerable` | The replacement scheme tags; an empty collection removes all tags. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when the shared source scheme identified by `schemeCode` does not exist. | `Task SetSchemeTagsAsync(string schemeCode, string? tenantId, IEnumerable tags)` Replaces all tags on a source scheme in an exact tenant scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The source scheme code. | | `tenantId` | `String` | The tenant identifier that defines the exact scope, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for the shared scope. | | `tags` | `IEnumerable` | The replacement scheme tags; an empty collection removes all tags. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no source scheme with `schemeCode` exists in the scope selected by `tenantId`. | `Task SetSchemeTagsAsync(string schemeCode, params string[] tags)` Replaces all tags on a source scheme in the shared scope. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the shared source scheme. | | `tags` | `String[]` | The replacement scheme tags; an empty array removes all tags. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when the shared source scheme identified by `schemeCode` does not exist. | `Task SetSchemeTagsInTenantAsync(string schemeCode, string tenantId, params string[] tags)` Replaces all tags on a source scheme in a specified tenant. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The source scheme code. | | `tenantId` | `String` | The tenant identifier that defines the exact scope. | | `tags` | `String[]` | The replacement scheme tags; an empty array removes all tags. | ### Returns | Type | Description | | --- | --- | | `Task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that represents the asynchronous operation. | ### Exceptions | Type | Description | | --- | --- | | `SchemeNotFoundException` | Thrown when no source scheme with `schemeCode` exists in the scope selected by `tenantId`. | [Previous IRuntimePersistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/IRuntimePersistence/) [Next IWorkflowProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/IWorkflowProvider/)