BaseDbSetting
This class is the base class of all IDbSetting-based classes.
Use-Cases
Use this class instead of the IDbSetting interface when overriding default database settings.
How to Implement?
Create a class that inherits this class and set the properties in the constructor.
public sealed class MyCustomSqlServerDbSetting : BaseDbSetting
{
public MyCustomSqlServerDbSetting()
: base()
{
AreTableHintsSupported = true;
AverageableType = typeof(double);
ClosingQuote = "]";
DefaultSchema = "dbo";
IsAffectedRowsSupported = true;
IsDirectionSupported = true;
IsExecuteReaderDisposable = true;
IsInsertAllBatchable = null;
IsMultiStatementExecutable = true;
IsPreparable = true;
IsTransactionSupported = true;
IsUseUpsert = false;
MaxParameterCount = 2098;
MultiStatementSeparator = ";";
OpeningQuote = "[";
ParameterPrefix = "@";
RequiresDbTypeBeforeValue = false;
SchemaSeparator = ".";
SkipsUnreferencedParameters = false;
SqlTextParameterPrefix = "@";
}
}
The
MaxParameterCountproperty caps the number of parameters/members the provider allows in a single generated command text — most directly, the number of values a singleWHERE 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. It defaults to2098(SQL Server’s ~2100 parameter ceiling, minus a small safety margin); override it for a provider with a lower hard limit (e.g. Firebird’s DSQL parser rejects anIN (...)list past 1500 members with “Implementation limit exceeded”).
The
MultiStatementSeparatorproperty is the string used to join the individual command texts generated by the QueryMultiple andQueryMultipleAsyncoperations into a single command text. It defaults to";". Override it for providers whose driver rejects a trailing statement terminator on an otherwise-standalone command, by giving it the provider’s own inter-statement separator instead.
The
IsInsertAllBatchableproperty overridesIsMultiStatementExecutablespecifically for whether InsertAll can batch more than one row into a single statement — a genuine multi-rowVALUES (...), (...), ...list, not multiple;-separated statements. It defaults tonull, which falls back toIsMultiStatementExecutable. Set it explicitly when a provider can support one but not the other: Vertica, for example, setsIsMultiStatementExecutable = false(its driver refuses a compound;-separated statement once it carries a parameter) butIsInsertAllBatchable = true, since a singleINSERT ... VALUES (...), (...)is still just one statement.
The
RequiresDbTypeBeforeValueproperty controls the orderDbParameter.DbTypeandDbParameter.Valueare assigned in. It defaults tofalse(Valuefirst); set it totruefor a provider whose driver lazily initializes internal parameter state inside theDbTypesetter and throws ifValueis assigned first on a parameter fresh offDbCommand.CreateParameter()— whentrue,DbTypeis assigned beforeValue, inferred from the value’s CLR type if not explicitly given.
The
SkipsUnreferencedParametersproperty controls whether a bound parameter with no corresponding placeholder in the generated command text is skipped rather than bound. It defaults tofalse. Set it totruefor a provider that strictly validates every bound parameter is actually referenced — a null-valued equality filter (e.g.WHERE "Id" = @Idwith anullvalue) is rendered by QueryField as the literal"Id" IS NULLwith no@Idplaceholder, so a strict provider would otherwise reject the whole command over the now-unreferenced parameter.
This class already implements
GetHashCode(), so no override is required.
Usability
Use the DbSettingMapper class to map the setting to a specific RDBMS provider.
DbSettingMapper.Add(typeof(SqlConnection), new MyCustomSqlServerDbSetting(), true);