Database Configuration Source
Where an overload does not supply a specific parameter, the following defaults will apply.
All defaults may be overridden by using the IConfiguration input parameter overload
Tablename = ConfigSetting
Database table name where the configuration setting data is stored
KeyCol = SettingKey
Database table column name for the configuration setting key
ValCol = SettingValue
Database table column name for the configuration setting value
AppIdCol = AppId
Database table column name used to identify the client application
AppIdVal = Calling Assembly (Client Application Project Name)
Used as the search filter parameter when calling the API. The API should return settings for this client only, based on the value of AppId.
SqlCommandTimeout = 0
Timeout value in seconds used by the SQL Command. (0 = infinite)
Adds the DbClient configuration source to the builder
May be used when initializing the Host before any other configuration or services have been loaded.
The calling assembly name (client project name) will be used as the default AppId.
public static IConfigurationBuilder AddDbSource(this IConfigurationBuilder builder, string connStringVar)
connStringVar String
Name of Environment Variable containing the SQL Server connection string
Adds the DbClient configuration source to the builder
May be used when initializing the Host before any services have been loaded by DI.
public static IConfigurationBuilder AddDbSource(this IConfigurationBuilder builder, string connStringVar, bool optional)
connStringVar String
Name of Environment Variable containing the SQL Server connection string
optional Boolean
When false, an exception will be thrown if the client is unable to connect to the database and execute the query.
Adds the DbClient configuration source to the builder
May be used when initializing the Host before any services have been loaded by DI.
public static IConfigurationBuilder AddDbSource(this IConfigurationBuilder builder, string connStringVar, string appId)
connStringVar String
Name of Environment Variable containing the SQL Server connection string
appId String
Used as the search filter parameter when calling the API. The API should return settings for this client only, based on the value of AppId.
Adds the DbClient configuration source to the builder
May be used when initializing the Host before any services have been loaded by DI.
public static IConfigurationBuilder AddDbSource(this IConfigurationBuilder builder, string connStringVar, string appId, bool optional)
connStringVar String
Name of Environment Variable containing the SQL Server connection string
appId String
Used as the search filter parameter when calling the API. The API should return settings for this client only, based on the value of AppId.
optional Boolean
When false, an exception will be thrown if the client is unable to connect to the database and execute the query.
Adds the DbClient configuration source to the builder
May be used when initializing the Host before any services have been loaded by DI.
public static IConfigurationBuilder AddDbSource(this IConfigurationBuilder builder, IConfiguration config, bool optional = false)
config IConfiguration
Instance of IConfiguration - must contain configuration section ConfigOptions:DbSource
optional Boolean (optional)
default: false An exception will be thrown if the client is unable to connect to the database and execute the query.
{
"ConfigOptions": {
"DbSource": {
"ConnString": "Server = (localdb)\\mssqllocaldb;Database=ConfigDb;Trusted_Connection=True;MultipleActiveResultSets=True;",
"TableName": "ConfigSetting",
"KeyCol": "SettingKey",
"ValCol": "SettingVal",
"AppIdCol": "AppId",
"AppIdVal": "CustomAppName",
"SqlCommandTimeout": "0",
}
}
}