IDbSetting

This interface is used to mark a class to be a database setting object. It allows you to control the behavior of the library on a specific RDBMS data provider based on the value you provided on the…

This interface is used to mark a class to be a database setting object. It allows you to control the behavior of the library on a specific RDBMS data provider based on the value you provided on the properties this class.

Properties

Below is the list of properties.

Name Description
AreTableHintsSupported Gets the value that indicates whether the table hints are supported.
ClosingQuote Gets the character used for closing quote.
AverageableType Gets the default averageable .NET CLR types for the database.
DefaultSchema Gets the default schema of the database.
IsAffectedRowsSupported Gets a value that indicates whether the current DB Provider supports returning the number of affected rows from the execution of a non-query command.
IsDirectionSupported Gets a value that indicates whether setting the value of DbParameter.Direction object is supported.
IsExecuteReaderDisposable Gets a value that indicates whether the DbCommand object must be disposed after calling the DbCommand.ExecuteReader() method.
IsInsertAllBatchable Gets a nullable value that overrides IsMultiStatementExecutable specifically for whether InsertAll can batch more than one row into a single statement (a genuine multi-row VALUES (...), (...), ... list, not multiple ;-separated statements). Left unset (null) by default, which falls back to IsMultiStatementExecutable. Set this when a provider supports a real multi-row VALUES list without supporting arbitrary compound statements.
IsMultiStatementExecutable Gets a value whether the multiple statement execution is supported.
IsPreparable Gets a value that indicates whether the current DB Provider supports the DbCommand.Prepare() calls.
IsTransactionSupported Gets a value that indicates whether the current DB Provider supports the transaction objects.
IsUseUpsert Gets a value that indicates whether the Insert/Update operation will be used for Merge operation.
MaxParameterCount Gets the maximum number of parameters/members the current DB provider allows in a single generated command text — most directly, the number of values a single WHERE column IN (...) clause can hold. Operations that batch a large key list into that shape (e.g. DeleteAll(keys)) split it into chunks no larger than this value before generating each chunk’s command text. Defaults to 2098 (SQL Server’s ~2100 parameter ceiling, minus a small safety margin).
MultiStatementSeparator Gets the string used to join the individual command texts generated by the QueryMultiple and QueryMultipleAsync operations into a single command text.
OpeningQuote Gets the character used for opening quote.
ParameterPrefix Gets the character used for the database command parameter prefixing.
RequiresDbTypeBeforeValue Gets a value that indicates whether DbParameter.DbType must be assigned (inferred from the value’s CLR type, if not explicitly given) before DbParameter.Value is set. Some providers lazily initialize internal parameter state inside the DbType setter and throw if Value is set first on a parameter fresh off DbCommand.CreateParameter(). Defaults to false.
SkipsUnreferencedParameters Gets a value that indicates whether the current DB Provider strictly validates that every parameter bound to the command is actually referenced by a placeholder in the generated DbCommand.CommandText, throwing when a bound parameter has no corresponding placeholder. A null-valued equality filter (e.g. WHERE "Id" = @Id with a null value) is rendered by QueryField as the literal "Id" IS NULL with no @Id placeholder at all, yet the parameter is still normally bound — most providers silently tolerate the unused parameter, but a strict provider rejects the whole command. When true, such unreferenced parameters are skipped instead of bound. Defaults to false.
SqlTextParameterPrefix Gets the character used for prefixing a parameter when it is embedded within a raw/text SQL statement, as opposed to when it is bound as a DbParameter object.

How to Implement?

You have to manually create a class that implements this interface.

public class MyCustomSqlServerDbSetting : IDbSetting
{
    public bool AreTableHintsSupported { get; set; } = true;
    public string ClosingQuote { get; set; } = "]";
    public Type AverageableType { get; set; } = typeof(double);
    public string DefaultSchema { get; set; } = "dbo";
    public bool IsAffectedRowsSupported { get; set; } = true;
    public bool IsDirectionSupported { get; set; } = true;
    public bool IsExecuteReaderDisposable { get; set; } = true;
    public bool? IsInsertAllBatchable { get; set; } = null;
    public bool IsMultiStatementExecutable { get; set; } = true;
    public bool IsPreparable { get; set; } = true;
    public bool IsTransactionSupported { get; set; } = true;
    public bool IsUseUpsert { get; set; } = false;
    public int MaxParameterCount { get; set; } = 2098;
    public string MultiStatementSeparator { get; set; } = ";";
    public string OpeningQuote { get; set; } = "[";
    public string ParameterPrefix { get; set; } = "@";
    public bool RequiresDbTypeBeforeValue { get; set; } = false;
    public bool SkipsUnreferencedParameters { get; set; } = false;
    public string SqlTextParameterPrefix { get; set; } = "@";
}

Please see the more detailed implementations at Database Setting page.

GetHashCode

You have to override the implementation of the GetHashCode() based on the combinations of the properties.

The reason to this, the library is using the equality based on the generated hashcode. Failure to comply may trigger a performance problem in your application.

We recommend to instead use the BaseDbSetting class when implementing a customized database setting.

Usability

Once the class has been implemented, you have to call the DbSettingMapper class for mappings (per RDBMS data provider).

DbSettingMapper.Add(typeof(SqlConnection), new CustomSqlServerDbSetting(), true);