Skip to main content

Introducing Formengine - The New Formbuilder, try for FREE formengine.io.

Database Provider

Data provider services in the Web API implement operations defined by the core services. There are currently six providers available, depending on the database management system (DBMS) you prefer.

info

Data provider services do not provide working API operations by themselves; building operations is handled by core services, so make sure to include them.

Integration

The database provider is distributed as a separate NuGet package. Add it to your project with the following command:

dotnet add package OptimaJet.Workflow.Api.Mssql

Add the provider during application startup by using an extension method on IServiceCollection:

builder.Services.AddWorkflowApiMssql();

You have now integrated the Web API data provider service.

Data Provider Options

You can configure data provider options by using the DataProviderCreationOptions property on WorkflowTenantCreationOptions. In single-tenant mode, this configuration is applied when the Workflow Runtime is initialized. In multi-tenant mode, it is applied separately for each tenant during registration. Below are the available options for each provider:

NameTypeDefaultDescription
DatabaseSchemastring?"dbo"The schema to which the provider's queries will be executed. If null is specified, the default will be used.
CommandTimeoutint30The timeout for command execution by the driver, in seconds.
ExceptionHandlerAction<Exception>_ => {}Delegate called before throwing an SQL exception within the provider. The encountered exception is passed as an argument.
LogQueryActionAction<string>_ => {}Delegate called after preparing the query for execution, with the SQL string passed as argument. Query parameters replaced with the '?' placeholder.

IWorkflowTenantProvider

Interface for providing workflow tenants in a multi-tenant setup.

info

Has a default implementation ListWorkflowTenantProvider that can be used to register list of tenants.

Tenants

An array of tenants to be registered in the Workflow Engine Web API.

Returns

TypeDescription
IWorkflowTenant[]An array of workflow tenants.

IProviderFactoryRegistry

Interface for a registry that manages and provides access to different providers factories

Get

Gets the provider factory for the specified database provider identifier. Default identifiers are stored in Core.PersistenceProviderId.

ParameterTypeDescription
providerIdstring?The identifier of the database provider (DBMS). If null, the default factory is returned.

Returns

TypeDescription
IProviderFactoryThe corresponding IProviderFactory instance, or the default factory if providerId is null.

GetDefault

Gets the first registered provider factory as the default.

Returns

TypeDescription
IProviderFactoryThe default IProviderFactory instance.

IProviderFactory

Interface for provider abstract factory used to create data provider and workflow provider implementations.

PersistenceProviderId

The identifier of the database management system, for which this factory creates providers. Default identifiers are stored in Core.PersistenceProviderId.

Returns

TypeDescription
stringThe persistence provider identifier.

CreateDataProvider

Creates a data provider for the specified connection string and options.

ParameterTypeDescription
connectionStringstringThe connection string to the database.
optionsDataProviderCreationOptionsThe options for configuring the data provider.

Returns

TypeDescription
IDataProviderAn instance of IDataProvider.

CreateWorkflowProvider

Creates a workflow provider with the specified options.

ParameterTypeDescription
optionsPersistenceProviderOptionsThe options for configuring the workflow provider.

Returns

TypeDescription
IWorkflowProviderAn instance of IWorkflowProvider.