Table of Contents

Class DataSourceOptions

Namespace
Quartz
Assembly
Quartz.dll

Strongly typed configuration for a single named ADO.NET data source.

public sealed class DataSourceOptions
Inheritance
DataSourceOptions
Inherited Members

Remarks

Registered as named options keyed by data source name, so a scheduler with several data sources configures each one under its own name. Typed replacement for the quartz.dataSource.<name>.* property keys.

Properties

ConnectionString

The connection string used to reach the database.

public string? ConnectionString { get; set; }

Property Value

string

Remarks

Takes precedence over ConnectionStringName when both are set.

ConnectionStringName

The name of a connection string to resolve from IConfiguration's connection strings.

public string? ConnectionStringName { get; set; }

Property Value

string

DataSourceFactory

Supplies the DbDataSource directly, for a data source that is built rather than registered. Wins over UseRegisteredDataSource and DataSourceServiceKey.

public Func<IServiceProvider, DbDataSource>? DataSourceFactory { get; set; }

Property Value

Func<IServiceProvider, DbDataSource>

Remarks

The factory runs once, when the store's connection provider is first resolved, and is given the container's service provider. Like DataSourceServiceKey it is settable from code only.

DataSourceServiceKey

The service key the DbDataSource is registered under, for an application that registers more than one. Setting it implies UseRegisteredDataSource.

public object? DataSourceServiceKey { get; set; }

Property Value

object

Remarks

An unkeyed DbDataSource is the container's one data source, so a process talking to two databases — a scheduler per tenant, or a reporting scheduler beside the application's own — has to key them apart. This says which key is this data source's.

A service key can be any object, so this is settable from code only: a configuration binder has no way to produce one. Configuration that needs to name a keyed data source therefore says so in a UseDataSource callback rather than in a Quartz:DataSource:<name> section.

Provider

The Quartz provider name identifying the ADO.NET driver.

public string Provider { get; set; }

Property Value

string

Remarks

The names Quartz ships a description for are on DataSourceOptions.Providers. Any other name works too, as long as something in the container describes it — see UseGenericDatabase.

UseRegisteredDataSource

Whether connections come from a DbDataSource registered in the container rather than from a connection string Quartz holds.

public bool UseRegisteredDataSource { get; set; }

Property Value

bool

Remarks

This is the third way a data source can say where its connections come from, alongside ConnectionString and ConnectionStringName, and it wins over both. It is a setting rather than a builder method because it answers the same question they do.