Class DataOptionsExtensions
- Namespace
- LinqToDB
- Assembly
- linq2db.dll
Set of extensions for DataOptions.
public static class DataOptionsExtensions
- Inheritance
-
DataOptionsExtensions
Methods
RemoveInterceptor(DataOptions, IInterceptor)
Removes IInterceptor instance from the context.
public static DataOptions RemoveInterceptor(this DataOptions options, IInterceptor interceptor)
Parameters
options
DataOptionsinterceptor
IInterceptor
Returns
UseAccess(DataOptions, string, Func<AccessOptions, AccessOptions>?)
Configure connection to use Access default provider and connection string.
public static DataOptions UseAccess(this DataOptions options, string connectionString, Func<AccessOptions, AccessOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringAccess connection string.
optionSetter
Func<AccessOptions, AccessOptions>Optional AccessOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider determined by inspecting connection string for OleDb or ODBC-specific markers and otherwise defaults to OleDb provider.
For more fine-grained configuration see UseAccessOleDb(DataOptions, string, Func<AccessOptions, AccessOptions>?) and UseAccessOdbc(DataOptions, Func<AccessOptions, AccessOptions>?) methods.UseAccessOdbc(DataOptions, Func<AccessOptions, AccessOptions>?)
Configure connection to use Access ODBC provider.
public static DataOptions UseAccessOdbc(this DataOptions options, Func<AccessOptions, AccessOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<AccessOptions, AccessOptions>Optional AccessOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseAccessOdbc(DataOptions, string, Func<AccessOptions, AccessOptions>?)
Configure connection to use Access ODBC provider and connection string.
public static DataOptions UseAccessOdbc(this DataOptions options, string connectionString, Func<AccessOptions, AccessOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringAccess connection string.
optionSetter
Func<AccessOptions, AccessOptions>Optional AccessOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseAccessOleDb(DataOptions, Func<AccessOptions, AccessOptions>?)
Configure connection to use Access OleDb provider.
public static DataOptions UseAccessOleDb(this DataOptions options, Func<AccessOptions, AccessOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<AccessOptions, AccessOptions>Optional AccessOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseAccessOleDb(DataOptions, string, Func<AccessOptions, AccessOptions>?)
Configure connection to use Access OleDb provider and connection string.
public static DataOptions UseAccessOleDb(this DataOptions options, string connectionString, Func<AccessOptions, AccessOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringAccess connection string.
optionSetter
Func<AccessOptions, AccessOptions>Optional AccessOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseAfterConnectionOpened(DataOptions, Action<DbConnection>, Func<DbConnection, CancellationToken, Task>?)
Sets custom actions, executed after connection opened.
public static DataOptions UseAfterConnectionOpened(this DataOptions options, Action<DbConnection> afterConnectionOpened, Func<DbConnection, CancellationToken, Task>? afterConnectionOpenedAsync = null)
Parameters
options
DataOptionsafterConnectionOpened
Action<DbConnection>Action, executed for connection instance after Open() call. Also called after OpenAsync(CancellationToken) call if
afterConnectionOpenedAsync
action is not provided. Accepts connection instance as parameter.afterConnectionOpenedAsync
Func<DbConnection, CancellationToken, Task>Action, executed for connection instance from async execution path after OpenAsync(CancellationToken) call. Accepts connection instance as parameter. If this option is not set,
afterConnectionOpened
synchronous action called. Use this option only if you need to perform async work from action, otherwiseafterConnectionOpened
is sufficient.
Returns
UseAse(DataOptions, Func<SybaseOptions, SybaseOptions>?)
Configure connection to use SAP/Sybase ASE default provider.
public static DataOptions UseAse(this DataOptions options, Func<SybaseOptions, SybaseOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<SybaseOptions, SybaseOptions>Optional SybaseOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Provider selection available only for .NET Framework applications.
Default provider will be chosen by probing current folder for provider assembly and if it is not found, default to official Sybase.AdoNet45.AseClient
provider.
UseAse(DataOptions, string, bool, Func<SybaseOptions, SybaseOptions>?)
Configure connection to use specific SAP/Sybase ASE provider and connection string.
public static DataOptions UseAse(this DataOptions options, string connectionString, bool useNativeProvider, Func<SybaseOptions, SybaseOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSAP/Sybase ASE connection string.
useNativeProvider
boolif
true
,Sybase.AdoNet45.AseClient
provider will be used; otherwise managedAdoNetCore.AseClient
.optionSetter
Func<SybaseOptions, SybaseOptions>Optional SybaseOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseAse(DataOptions, string, Func<SybaseOptions, SybaseOptions>?)
Configure connection to use SAP/Sybase ASE default provider and connection string.
public static DataOptions UseAse(this DataOptions options, string connectionString, Func<SybaseOptions, SybaseOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSAP/Sybase ASE connection string.
optionSetter
Func<SybaseOptions, SybaseOptions>Optional SybaseOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Provider selection available only for .NET Framework applications.
Default provider will be choosen by probing current folder for provider assembly and if it is not found, default to official Sybase.AdoNet45.AseClient
provider.
UseBeforeConnectionOpened(DataOptions, Action<DbConnection>, Func<DbConnection, CancellationToken, Task>?)
Sets custom actions, executed before connection opened.
public static DataOptions UseBeforeConnectionOpened(this DataOptions options, Action<DbConnection> afterConnectionOpening, Func<DbConnection, CancellationToken, Task>? afterConnectionOpeningAsync = null)
Parameters
options
DataOptionsafterConnectionOpening
Action<DbConnection>Action, executed before database connection opened. Accepts connection instance as parameter.
afterConnectionOpeningAsync
Func<DbConnection, CancellationToken, Task>Action, executed after database connection opened from async execution path. Accepts connection instance as parameter. If this option is not set,
afterConnectionOpening
synchronous action called. Use this option only if you need to perform async work from action, otherwiseafterConnectionOpening
is sufficient.
Returns
UseBulkCopyCheckConstraints(DataOptions, bool?)
Enables database constrains enforcement during bulk copy operation. Supported with ProviderSpecific bulk copy mode for following databases:
- Oracle
- SQL Server
- SAP/Sybase ASE
public static DataOptions UseBulkCopyCheckConstraints(this DataOptions options, bool? checkConstraints)
Parameters
options
DataOptionscheckConstraints
bool?
Returns
UseBulkCopyDatabaseName(DataOptions, string?)
Gets or sets explicit name of target database instead of one, configured for copied entity in mapping schema. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
public static DataOptions UseBulkCopyDatabaseName(this DataOptions options, string? databaseName)
Parameters
options
DataOptionsdatabaseName
string
Returns
UseBulkCopyFireTriggers(DataOptions, bool?)
Enables insert triggers during bulk copy operation. Supported with ProviderSpecific bulk copy mode for following databases:
- Oracle
- SQL Server
- SAP/Sybase ASE
public static DataOptions UseBulkCopyFireTriggers(this DataOptions options, bool? fireTriggers)
Parameters
options
DataOptionsfireTriggers
bool?
Returns
UseBulkCopyKeepIdentity(DataOptions, bool?)
If this option set to true, bulk copy will use values of columns, marked with IsIdentity flag. SkipOnInsert flag in this case will be ignored. Otherwise those columns will be skipped and values will be generated by server. Not compatible with RowByRow mode.
public static DataOptions UseBulkCopyKeepIdentity(this DataOptions options, bool? keepIdentity)
Parameters
options
DataOptionskeepIdentity
bool?
Returns
UseBulkCopyKeepNulls(DataOptions, bool?)
Enables instert of NULL
values instead of values from colum default constraint during bulk copy operation.
Supported with ProviderSpecific bulk copy mode for following databases:
- SQL Server
- SAP/Sybase ASE
public static DataOptions UseBulkCopyKeepNulls(this DataOptions options, bool? keepNulls)
Parameters
options
DataOptionskeepNulls
bool?
Returns
UseBulkCopyMaxBatchSize(DataOptions, int?)
Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server. Returns an integer value or zero if no value has been set.
public static DataOptions UseBulkCopyMaxBatchSize(this DataOptions options, int? maxBatchSize)
Parameters
options
DataOptionsmaxBatchSize
int?
Returns
UseBulkCopyMaxDegreeOfParallelism(DataOptions, int?)
Implemented only by ClickHouse.Client provider. Defines number of connections, used for parallel insert in ProviderSpecific mode.
public static DataOptions UseBulkCopyMaxDegreeOfParallelism(this DataOptions options, int? maxDegreeOfParallelism)
Parameters
options
DataOptionsmaxDegreeOfParallelism
int?
Returns
UseBulkCopyMaxParametersForBatch(DataOptions, int?)
If set, will override the Maximum parameters per batch statement from MaxParameters.
public static DataOptions UseBulkCopyMaxParametersForBatch(this DataOptions options, int? maxParametersForBatch)
Parameters
options
DataOptionsmaxParametersForBatch
int?
Returns
UseBulkCopyNotifyAfter(DataOptions, int)
Gets or sets counter after how many copied records RowsCopiedCallback should be called. E.g. if you set it to 10, callback will be called after each 10 copied records. To disable callback, set this option to 0 (default value).
public static DataOptions UseBulkCopyNotifyAfter(this DataOptions options, int notifyAfter)
Parameters
options
DataOptionsnotifyAfter
int
Returns
UseBulkCopyRowsCopiedCallback(DataOptions, Action<BulkCopyRowsCopied>?)
Gets or sets callback method that will be called by BulkCopy operation after each NotifyAfter rows copied. This callback will not be used if NotifyAfter set to 0.
public static DataOptions UseBulkCopyRowsCopiedCallback(this DataOptions options, Action<BulkCopyRowsCopied>? rowsCopiedCallback)
Parameters
options
DataOptionsrowsCopiedCallback
Action<BulkCopyRowsCopied>
Returns
UseBulkCopySchemaName(DataOptions, string?)
Gets or sets explicit name of target schema/owner instead of one, configured for copied entity in mapping schema. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
public static DataOptions UseBulkCopySchemaName(this DataOptions options, string? schemaName)
Parameters
options
DataOptionsschemaName
string
Returns
UseBulkCopyServerName(DataOptions, string?)
Gets or sets explicit name of target server instead of one, configured for copied entity in mapping schema. See ServerName<T>(ITable<T>, string?) method for support information per provider. Also note that it is not supported by provider-specific insert method.
public static DataOptions UseBulkCopyServerName(this DataOptions options, string? serverName)
Parameters
options
DataOptionsserverName
string
Returns
UseBulkCopyTableLock(DataOptions, bool?)
Applies table lock during bulk copy operation. Supported with ProviderSpecific bulk copy mode for following databases:
- DB2
- Informix (using DB2 provider)
- SQL Server
- SAP/Sybase ASE
public static DataOptions UseBulkCopyTableLock(this DataOptions options, bool? tableLock)
Parameters
options
DataOptionstableLock
bool?
Returns
UseBulkCopyTableName(DataOptions, string?)
Gets or sets explicit name of target table instead of one, configured for copied entity in mapping schema.
public static DataOptions UseBulkCopyTableName(this DataOptions options, string? tableName)
Parameters
options
DataOptionstableName
string
Returns
UseBulkCopyTableOptions(DataOptions, TableOptions)
Gets or sets TableOptions flags overrides instead of configured for copied entity in mapping schema. See IsTemporary<T>(ITable<T>, bool) method for support information per provider.
public static DataOptions UseBulkCopyTableOptions(this DataOptions options, TableOptions tableOptions)
Parameters
options
DataOptionstableOptions
TableOptions
Returns
UseBulkCopyTimeout(DataOptions, int?)
Number of seconds for the operation to complete before it times out.
public static DataOptions UseBulkCopyTimeout(this DataOptions options, int? bulkCopyTimeout)
Parameters
options
DataOptionsbulkCopyTimeout
int?
Returns
UseBulkCopyType(DataOptions, BulkCopyType)
Specify bulk copy implementation type.
public static DataOptions UseBulkCopyType(this DataOptions options, BulkCopyType bulkCopyType)
Parameters
options
DataOptionsbulkCopyType
BulkCopyType
Returns
UseBulkCopyUseInternalTransaction(DataOptions, bool?)
Enables automatic transaction creation during bulk copy operation. Supported with ProviderSpecific bulk copy mode for following databases:
- Oracle
- SQL Server
- SAP/Sybase ASE
public static DataOptions UseBulkCopyUseInternalTransaction(this DataOptions options, bool? useInternalTransaction)
Parameters
options
DataOptionsuseInternalTransaction
bool?
Returns
UseBulkCopyUseParameters(DataOptions, bool)
Gets or sets whether to Always use Parameters for MultipleRowsCopy. Default is false. If True, provider's override for MaxParameters will be used to determine the maximum number of rows per insert, Unless overridden by MaxParametersForBatch.
public static DataOptions UseBulkCopyUseParameters(this DataOptions options, bool useParameters)
Parameters
options
DataOptionsuseParameters
bool
Returns
UseBulkCopyWithoutSession(DataOptions, bool)
Implemented only by ClickHouse.Client provider. When set, provider-specific bulk copy will use session-less connection even if called over connection with session. Note that session-less connections cannot be used with session-bound functionality like temporary tables.
public static DataOptions UseBulkCopyWithoutSession(this DataOptions options, bool withoutSession)
Parameters
options
DataOptionswithoutSession
bool
Returns
UseCacheSlidingExpiration(DataOptions, TimeSpan?)
Specifies timeout when query will be evicted from cache since last execution of query. Default value is 1 hour.
public static DataOptions UseCacheSlidingExpiration(this DataOptions options, TimeSpan? cacheSlidingExpiration)
Parameters
options
DataOptionscacheSlidingExpiration
TimeSpan?
Returns
UseClickHouse(DataOptions, ClickHouseProvider, Func<ClickHouseOptions, ClickHouseOptions>?)
Configure connection to use UseClickHouse provider.
public static DataOptions UseClickHouse(this DataOptions options, ClickHouseProvider provider, Func<ClickHouseOptions, ClickHouseOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
provider
ClickHouseProviderClickHouse provider.
optionSetter
Func<ClickHouseOptions, ClickHouseOptions>Optional ClickHouseOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseClickHouse(DataOptions, ClickHouseProvider, string, Func<ClickHouseOptions, ClickHouseOptions>?)
Configure connection to use UseClickHouse provider and connection string.
public static DataOptions UseClickHouse(this DataOptions options, ClickHouseProvider provider, string connectionString, Func<ClickHouseOptions, ClickHouseOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
provider
ClickHouseProviderClickHouse provider.
connectionString
stringClickHouse connection string.
optionSetter
Func<ClickHouseOptions, ClickHouseOptions>Optional ClickHouseOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseCoefficient(DataOptions, TimeSpan)
The coefficient for the exponential function used to compute the delay between retries, must be nonnegative. Default value: 1 second.
public static DataOptions UseCoefficient(this DataOptions options, TimeSpan coefficient)
Parameters
options
DataOptionscoefficient
TimeSpan
Returns
UseCompareNullsAsValues(DataOptions, bool)
If set to true nullable fields would be checked for IS NULL in Equal/NotEqual comparisons.
This affects: Equal, NotEqual, Not Contains
Default value: true
.
public static DataOptions UseCompareNullsAsValues(this DataOptions options, bool compareNullsAsValues)
Parameters
options
DataOptionscompareNullsAsValues
bool
Returns
Examples
public class MyEntity
{
public int? Value;
}
db.MyEntity.Where(e => e.Value != 10)
from e1 in db.MyEntity
join e2 in db.MyEntity on e1.Value equals e2.Value
select e1
var filter = new [] {1, 2, 3};
db.MyEntity.Where(e => ! filter.Contains(e.Value))
Would be converted to next queries:
SELECT Value FROM MyEntity WHERE Value IS NULL OR Value != 10
SELECT e1.Value
FROM MyEntity e1
INNER JOIN MyEntity e2 ON e1.Value = e2.Value OR (e1.Value IS NULL AND e2.Value IS NULL)
SELECT Value FROM MyEntity WHERE Value IS NULL OR NOT Value IN (1, 2, 3)
UseConfiguration(DataOptions, string?)
Defines configuration sting to use with DataOptions.
public static DataOptions UseConfiguration(this DataOptions options, string? configurationString)
Parameters
options
DataOptionsconfigurationString
string
Returns
UseConfiguration(DataOptions, string, MappingSchema)
Defines configuration sting and MappingSchema to use with DataOptions.
public static DataOptions UseConfiguration(this DataOptions options, string configurationString, MappingSchema mappingSchema)
Parameters
options
DataOptionsconfigurationString
stringmappingSchema
MappingSchema
Returns
UseConfigurationString(DataOptions, string?)
Defines configuration sting to use with DataOptions.
public static DataOptions UseConfigurationString(this DataOptions options, string? configurationString)
Parameters
options
DataOptionsconfigurationString
string
Returns
UseConfigurationString(DataOptions, string, MappingSchema)
Defines configuration sting and MappingSchema to use with DataOptions.
public static DataOptions UseConfigurationString(this DataOptions options, string configurationString, MappingSchema mappingSchema)
Parameters
options
DataOptionsconfigurationString
stringmappingSchema
MappingSchema
Returns
UseConnection(DataOptions, IDataProvider, DbConnection)
Defines data provider and DbConnection to use with DataOptions.
public static DataOptions UseConnection(this DataOptions options, IDataProvider dataProvider, DbConnection connection)
Parameters
options
DataOptionsdataProvider
IDataProviderconnection
DbConnection
Returns
UseConnection(DataOptions, IDataProvider, DbConnection, bool)
Defines data provider and DbConnection to use with DataOptions.
public static DataOptions UseConnection(this DataOptions options, IDataProvider dataProvider, DbConnection connection, bool disposeConnection)
Parameters
options
DataOptionsdataProvider
IDataProviderconnection
DbConnectiondisposeConnection
bool
Returns
UseConnection(DataOptions, DbConnection)
Defines DbConnection to use with DataOptions.
public static DataOptions UseConnection(this DataOptions options, DbConnection connection)
Parameters
options
DataOptionsconnection
DbConnection
Returns
UseConnectionFactory(DataOptions, IDataProvider, Func<DataOptions, DbConnection>)
Defines data provider and connection factory to use with DataOptions.
public static DataOptions UseConnectionFactory(this DataOptions options, IDataProvider dataProvider, Func<DataOptions, DbConnection> connectionFactory)
Parameters
options
DataOptionsdataProvider
IDataProviderconnectionFactory
Func<DataOptions, DbConnection>
Returns
UseConnectionFactory(DataOptions, Func<DataOptions, DbConnection>)
Defines connection factory to use with DataOptions.
public static DataOptions UseConnectionFactory(this DataOptions options, Func<DataOptions, DbConnection> connectionFactory)
Parameters
options
DataOptionsconnectionFactory
Func<DataOptions, DbConnection>
Returns
UseConnectionString(DataOptions, IDataProvider, string)
Defines data provider and connection sting to use with DataOptions.
public static DataOptions UseConnectionString(this DataOptions options, IDataProvider dataProvider, string connectionString)
Parameters
options
DataOptionsdataProvider
IDataProviderconnectionString
string
Returns
UseConnectionString(DataOptions, string)
Defines connection sting to use with DataOptions.
public static DataOptions UseConnectionString(this DataOptions options, string connectionString)
Parameters
options
DataOptionsconnectionString
string
Returns
UseConnectionString(DataOptions, string, string)
Defines provider name and connection sting to use with DataOptions.
public static DataOptions UseConnectionString(this DataOptions options, string providerName, string connectionString)
Parameters
options
DataOptionsproviderName
stringconnectionString
string
Returns
UseDB2(DataOptions, DB2Version, Func<DB2Options, DB2Options>?)
Configure connection to use specific DB2 provider.
public static DataOptions UseDB2(this DataOptions options, DB2Version version, Func<DB2Options, DB2Options>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
version
DB2VersionDB2 server version.
optionSetter
Func<DB2Options, DB2Options>Optional DB2Options configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseDB2(DataOptions, string, DB2Version, Func<DB2Options, DB2Options>?)
Configure connection to use specific DB2 provider and connection string.
public static DataOptions UseDB2(this DataOptions options, string connectionString, DB2Version version, Func<DB2Options, DB2Options>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringDB2 connection string.
version
DB2VersionDB2 server version.
optionSetter
Func<DB2Options, DB2Options>Optional DB2Options configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseDB2(DataOptions, string, Func<DB2Options, DB2Options>?)
Configure connection to use DB2 default provider and connection string.
public static DataOptions UseDB2(this DataOptions options, string connectionString, Func<DB2Options, DB2Options>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringDB2 connection string.
optionSetter
Func<DB2Options, DB2Options>Optional DB2Options configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
DB2 provider will be chosen automatically:
- if AutoDetectProvider (default:
true
) enabled, LinqToDB will query server for version - otherwise
DB2 LUW
provider will be chosen.
UseDataProvider(DataOptions, IDataProvider)
Defines data provider to use with DataOptions.
public static DataOptions UseDataProvider(this DataOptions options, IDataProvider dataProvider)
Parameters
options
DataOptionsdataProvider
IDataProvider
Returns
UseDataProviderFactory(DataOptions, Func<ConnectionOptions, IDataProvider>)
Sets DataProviderFactory option.
public static DataOptions UseDataProviderFactory(this DataOptions options, Func<ConnectionOptions, IDataProvider> dataProviderFactory)
Parameters
options
DataOptionsdataProviderFactory
Func<ConnectionOptions, IDataProvider>
Returns
UseDefaultRetryPolicyFactory(DataOptions)
Uses default retry policy factory.
public static DataOptions UseDefaultRetryPolicyFactory(this DataOptions options)
Parameters
options
DataOptions
Returns
UseDisableQueryCache(DataOptions, bool)
Used to disable LINQ expressions caching for queries. This cache reduces time, required for query parsing but have several side-effects:
- cached LINQ expressions could contain references to external objects as parameters, which could lead to memory leaks if those objects are not used anymore by other code - cache access synchronization could lead to bigger latencies than it saves. Default value:false
.
It is not recommended to enable this option as it could lead to severe slowdown. Better approach will be
to call ClearCache() method to cleanup cache after queries, that produce severe memory leaks you need to fix.
More details.
public static DataOptions UseDisableQueryCache(this DataOptions options, bool disableQueryCache)
Parameters
options
DataOptionsdisableQueryCache
bool
Returns
UseDoNotClearOrderBys(DataOptions, bool)
Controls behavior, when LINQ query chain contains multiple OrderBy<TSource, TKey>(IQueryable<TSource>, Expression<Func<TSource, TKey>>) or OrderByDescending<TSource, TKey>(IQueryable<TSource>, Expression<Func<TSource, TKey>>) calls:
- if
true
- non-first OrderBy* call will be treated as ThenBy* call; - if
false
- OrderBy* call will discard sort specifications, added by previous OrderBy* and ThenBy* calls. Default value:false
.
public static DataOptions UseDoNotClearOrderBys(this DataOptions options, bool doNotClearOrderBys)
Parameters
options
DataOptionsdoNotClearOrderBys
bool
Returns
UseEnableConstantExpressionInOrderBy(DataOptions, bool)
If true
, linq2db will allow any constant expressions in ORDER BY clause.
Default value: false
.
public static DataOptions UseEnableConstantExpressionInOrderBy(this DataOptions options, bool enableConstantExpressionInOrderBy)
Parameters
options
DataOptionsenableConstantExpressionInOrderBy
bool
Returns
UseEnableContextSchemaEdit(DataOptions, bool)
If true
, user could add new mappings to context mapping schems (MappingSchema).
Otherwise, LinqToDBException will be generated on locked mapping schema edit attempt.
It is not recommended to enable this option as it has performance implications.
Proper approach is to create single MappingSchema instance once, configure mappings for it and use this MappingSchema instance for all context instances.
public static DataOptions UseEnableContextSchemaEdit(this DataOptions options, bool enableContextSchemaEdit)
Parameters
options
DataOptionsenableContextSchemaEdit
bool
Returns
UseExponentialBase(DataOptions, double)
The base for the exponential function used to compute the delay between retries, must be positive.
Default value: 2
.
public static DataOptions UseExponentialBase(this DataOptions options, double exponentialBase)
Parameters
options
DataOptionsexponentialBase
double
Returns
UseFactory(DataOptions, Func<DataConnection, IRetryPolicy?>?)
Retry policy factory method, used to create retry policy for new DataConnection instance. If factory method is not set, retry policy is not used. Not set by default.
public static DataOptions UseFactory(this DataOptions options, Func<DataConnection, IRetryPolicy?>? factory)
Parameters
options
DataOptionsfactory
Func<DataConnection, IRetryPolicy>
Returns
UseFirebird(DataOptions, Func<FirebirdOptions, FirebirdOptions>?)
Configure connection to use Firebird provider.
public static DataOptions UseFirebird(this DataOptions options, Func<FirebirdOptions, FirebirdOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<FirebirdOptions, FirebirdOptions>Optional FirebirdOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseFirebird(DataOptions, string, Func<FirebirdOptions, FirebirdOptions>?)
Configure connection to use Firebird provider and connection string.
public static DataOptions UseFirebird(this DataOptions options, string connectionString, Func<FirebirdOptions, FirebirdOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringFirebird connection string.
optionSetter
Func<FirebirdOptions, FirebirdOptions>Optional FirebirdOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseGenerateExpressionTest(DataOptions, bool)
Enables generation of test class for each LINQ query, executed while this option is enabled.
This option could be useful for issue reporting, when you need to provide reproducible case.
Test file will be placed to linq2db
subfolder of temp folder and exact file path will be logged
to data connection tracing infrastructure.
See TraceSwitch for more details.
Default value: false
.
public static DataOptions UseGenerateExpressionTest(this DataOptions options, bool generateExpressionTest)
Parameters
options
DataOptionsgenerateExpressionTest
bool
Returns
UseGenerateFinalAliases(DataOptions, bool)
Indicates whether SQL Builder should generate aliases for final projection. It is not required for correct query processing but simplifies SQL analysis.
Default value: false
.
var query = from child in db.Child
select new
{
TrackId = child.ChildID,
};
When property is true
SELECT
[child].[ChildID] as [TrackId]
FROM
[Child] [child]
Otherwise alias will be removed
SELECT
[child].[ChildID]
FROM
[Child] [child]
public static DataOptions UseGenerateFinalAliases(this DataOptions options, bool generateFinalAliases)
Parameters
options
DataOptionsgenerateFinalAliases
bool
Returns
UseGuardGrouping(DataOptions, bool)
Controls behavior of LINQ query, which ends with GroupBy call.
- if
true
- LinqToDBException will be thrown for such queries; - if
false
- behavior is controlled by UsePreloadGroups(DataOptions, bool) option. Default value:true
.
public static DataOptions UseGuardGrouping(this DataOptions options, bool guardGrouping)
Parameters
options
DataOptionsguardGrouping
bool
Returns
Remarks
UseIgnoreEmptyUpdate(DataOptions, bool)
Controls behavior of linq2db
when there is no updateable fields in Update query:
- if
true
- query not executed and Update operation returns 0 as number of affected records; - if
false
- LinqToDBException will be thrown. Default value:false
.
public static DataOptions UseIgnoreEmptyUpdate(DataOptions options, bool ignoreEmptyUpdate)
Parameters
options
DataOptionsignoreEmptyUpdate
bool
Returns
UseInformix(DataOptions, Func<InformixOptions, InformixOptions>?)
Configure connection to use Informix default provider.
public static DataOptions UseInformix(this DataOptions options, Func<InformixOptions, InformixOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<InformixOptions, InformixOptions>Optional InformixOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider will be chosen by probing current folder for provider assembly and if it is not found, default to IBM.Data.DB2
provider.
This is not applicable to .NET Core applications as they always use IBM.Data.DB2
provider.
UseInformix(DataOptions, string, bool, Func<InformixOptions, InformixOptions>?)
Configure connection to use specific Informix provider and connection string.
public static DataOptions UseInformix(this DataOptions options, string connectionString, bool useDB2Provider, Func<InformixOptions, InformixOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringInformix connection string.
useDB2Provider
boolif
true
,IBM.Data.DB2
provider will be used; otherwiseIBM.Data.Informix
.optionSetter
Func<InformixOptions, InformixOptions>Optional InformixOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseInformix(DataOptions, string, Func<InformixOptions, InformixOptions>?)
Configure connection to use Informix default provider and connection string.
public static DataOptions UseInformix(this DataOptions options, string connectionString, Func<InformixOptions, InformixOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringInformix connection string.
optionSetter
Func<InformixOptions, InformixOptions>Optional InformixOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider will be chosen by probing current folder for provider assembly and if it is not found, default to IBM.Data.DB2
provider.
This is not applicable to .NET Core applications as they always use IBM.Data.DB2
provider.
UseInterceptor(DataOptions, IInterceptor)
Adds IInterceptor instance to those registered on the context.
Interceptors can be used to view, change, or suppress operations taken by linq2db
.
See the specific implementations of IInterceptor for details. For example, 'ICommandInterceptor'.
Extensions can also register multiple IInterceptors in the internal service provider. If both injected and application interceptors are found, then the injected interceptors are run in the order that they are resolved from the service provider, and then the application interceptors are run in the order that they were added to the context.
Calling this method multiple times will result in all interceptors in every call being added to the context. Interceptors added in a previous call are not overridden by interceptors added in a later call.
public static DataOptions UseInterceptor(this DataOptions options, IInterceptor interceptor)
Parameters
options
DataOptionsinterceptor
IInterceptorThe interceptor to add.
Returns
- DataOptions
The same builder instance so that multiple calls can be chained.
UseInterceptors(DataOptions, params IInterceptor[])
Adds IInterceptor instances to those registered on the context.
Interceptors can be used to view, change, or suppress operations taken by linq2db
.
See the specific implementations of IInterceptor for details. For example, 'ICommandInterceptor'.
Extensions can also register multiple IInterceptors in the internal service provider. If both injected and application interceptors are found, then the injected interceptors are run in the order that they are resolved from the service provider, and then the application interceptors are run in the order that they were added to the context.
Calling this method multiple times will result in all interceptors in every call being added to the context. Interceptors added in a previous call are not overridden by interceptors added in a later call.
public static DataOptions UseInterceptors(this DataOptions options, params IInterceptor[] interceptors)
Parameters
options
DataOptionsinterceptors
IInterceptor[]The interceptors to add.
Returns
- DataOptions
The same builder instance so that multiple calls can be chained.
UseInterceptors(DataOptions, IEnumerable<IInterceptor>)
Adds IInterceptor instances to those registered on the context.
Interceptors can be used to view, change, or suppress operations taken by linq2db
.
See the specific implementations of IInterceptor for details. For example, 'ICommandInterceptor'.
A single interceptor instance can implement multiple different interceptor interfaces. I will be registered as an interceptor for all interfaces that it implements.
Extensions can also register multiple IInterceptors in the internal service provider. If both injected and application interceptors are found, then the injected interceptors are run in the order that they are resolved from the service provider, and then the application interceptors are run in the order that they were added to the context.
Calling this method multiple times will result in all interceptors in every call being added to the context. Interceptors added in a previous call are not overridden by interceptors added in a later call.
public static DataOptions UseInterceptors(this DataOptions options, IEnumerable<IInterceptor> interceptors)
Parameters
options
DataOptionsinterceptors
IEnumerable<IInterceptor>The interceptors to add.
Returns
- DataOptions
The same builder instance so that multiple calls can be chained.
UseKeepDistinctOrdered(DataOptions, bool)
Allows SQL generation to automatically transform
SELECT DISTINCT value FROM Table ORDER BY date
Into GROUP BY equivalent if syntax is not supported
Default value: true
.
public static DataOptions UseKeepDistinctOrdered(this DataOptions options, bool keepDistinctOrdered)
Parameters
options
DataOptionskeepDistinctOrdered
bool
Returns
UseMappingSchema(DataOptions, MappingSchema)
Defines mapping schema to use with DataOptions.
public static DataOptions UseMappingSchema(this DataOptions options, MappingSchema mappingSchema)
Parameters
options
DataOptionsmappingSchema
MappingSchema
Returns
UseMaxDelay(DataOptions, TimeSpan)
The maximum time delay between retries, must be nonnegative. Default value: 30 seconds.
public static DataOptions UseMaxDelay(this DataOptions options, TimeSpan defaultMaxDelay)
Parameters
options
DataOptionsdefaultMaxDelay
TimeSpan
Returns
UseMaxRetryCount(DataOptions, int)
The number of retry attempts.
Default value: 5
.
public static DataOptions UseMaxRetryCount(this DataOptions options, int maxRetryCount)
Parameters
options
DataOptionsmaxRetryCount
int
Returns
UseMySql(DataOptions, Func<MySqlOptions, MySqlOptions>?)
Configure connection to use MySql default provider.
public static DataOptions UseMySql(this DataOptions options, Func<MySqlOptions, MySqlOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<MySqlOptions, MySqlOptions>Optional MySqlOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider will be chosen by probing current folder for provider assembly and if it is not found, default to MySql.Data
provider.
UseMySql(DataOptions, string, Func<MySqlOptions, MySqlOptions>?)
Configure connection to use MySql default provider and connection string.
public static DataOptions UseMySql(this DataOptions options, string connectionString, Func<MySqlOptions, MySqlOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringMySql connection string.
optionSetter
Func<MySqlOptions, MySqlOptions>Optional MySqlOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider will be chosen by probing current folder for provider assembly and if it is not found, default to MySql.Data
provider.
UseMySqlConnector(DataOptions, Func<MySqlOptions, MySqlOptions>?)
Configure connection to use MySqlConnector
MySql provider.
public static DataOptions UseMySqlConnector(this DataOptions options, Func<MySqlOptions, MySqlOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<MySqlOptions, MySqlOptions>Optional MySqlOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseMySqlConnector(DataOptions, string, Func<MySqlOptions, MySqlOptions>?)
Configure connection to use MySqlConnector
MySql provider and connection string.
public static DataOptions UseMySqlConnector(this DataOptions options, string connectionString, Func<MySqlOptions, MySqlOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringMySql connection string.
optionSetter
Func<MySqlOptions, MySqlOptions>Optional MySqlOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseMySqlData(DataOptions, Func<MySqlOptions, MySqlOptions>?)
Configure connection to use MySql.Data
MySql provider.
public static DataOptions UseMySqlData(this DataOptions options, Func<MySqlOptions, MySqlOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<MySqlOptions, MySqlOptions>Optional MySqlOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseMySqlData(DataOptions, string, Func<MySqlOptions, MySqlOptions>?)
Configure connection to use MySql.Data
MySql provider and connection string.
public static DataOptions UseMySqlData(this DataOptions options, string connectionString, Func<MySqlOptions, MySqlOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringMySql connection string.
optionSetter
Func<MySqlOptions, MySqlOptions>Optional MySqlOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseOnEntityDescriptorCreated(DataOptions, Action<MappingSchema, IEntityChangeDescriptor>)
Defines entity descriptor creation callback to use with DataOptions.
public static DataOptions UseOnEntityDescriptorCreated(this DataOptions options, Action<MappingSchema, IEntityChangeDescriptor> onEntityDescriptorCreated)
Parameters
options
DataOptionsonEntityDescriptorCreated
Action<MappingSchema, IEntityChangeDescriptor>
Returns
UseOptimizeJoins(DataOptions, bool)
If enabled, linq2db
will try to reduce number of generated SQL JOINs for LINQ query.
Attempted optimizations:
- removes duplicate joins by unique target table key;
- removes self-joins by unique key;
- removes left joins if joined table is not used in query.
Default value:
true
.
public static DataOptions UseOptimizeJoins(this DataOptions options, bool optimizeJoins)
Parameters
options
DataOptionsoptimizeJoins
bool
Returns
UseOracle(DataOptions, OracleVersion, OracleProvider, Func<OracleOptions, OracleOptions>?)
Configure connection to use specific Oracle provider, dialect and provider-specific options.
public static DataOptions UseOracle(this DataOptions options, OracleVersion dialect, OracleProvider provider, Func<OracleOptions, OracleOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
dialect
OracleVersionOracle dialect support level.
provider
OracleProviderADO.NET provider to use.
optionSetter
Func<OracleOptions, OracleOptions>Optional OracleOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseOracle(DataOptions, string, OracleProvider, Func<OracleOptions, OracleOptions>?)
Configure connection to use specific Oracle provider and connection string.
public static DataOptions UseOracle(this DataOptions options, string connectionString, OracleProvider provider, Func<OracleOptions, OracleOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringOracle connection string.
provider
OracleProviderADO.NET provider to use.
optionSetter
Func<OracleOptions, OracleOptions>Optional OracleOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseOracle(DataOptions, string, OracleVersion, OracleProvider, Func<OracleOptions, OracleOptions>?)
Configure connection to use specific Oracle provider, dialect and connection string.
public static DataOptions UseOracle(this DataOptions options, string connectionString, OracleVersion dialect, OracleProvider provider, Func<OracleOptions, OracleOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringOracle connection string.
dialect
OracleVersionOracle dialect support level.
provider
OracleProviderADO.NET provider to use.
optionSetter
Func<OracleOptions, OracleOptions>Optional OracleOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseOracle(DataOptions, string, Func<OracleOptions, OracleOptions>?)
Configure connection to use Oracle default provider, specific dialect and connection string.
public static DataOptions UseOracle(this DataOptions options, string connectionString, Func<OracleOptions, OracleOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringOracle connection string.
optionSetter
Func<OracleOptions, OracleOptions>Optional OracleOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
By default LinqToDB tries to load managed version of Oracle provider.
UseParameterizeTakeSkip(DataOptions, bool)
Enables Take/Skip parameterization.
Default value: true
.
public static DataOptions UseParameterizeTakeSkip(this DataOptions options, bool parameterizeTakeSkip)
Parameters
options
DataOptionsparameterizeTakeSkip
bool
Returns
UsePostgreSQL(DataOptions, PostgreSQLVersion, Func<PostgreSQLOptions, PostgreSQLOptions>?)
Configure connection to use PostgreSQL Npgsql provider, specific dialect and provider-specific options.
public static DataOptions UsePostgreSQL(this DataOptions options, PostgreSQLVersion dialect = PostgreSQLVersion.AutoDetect, Func<PostgreSQLOptions, PostgreSQLOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
dialect
PostgreSQLVersionPostgreSQL dialect support level.
optionSetter
Func<PostgreSQLOptions, PostgreSQLOptions>Optional PostgreSQLOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UsePostgreSQL(DataOptions, string, PostgreSQLVersion, Func<PostgreSQLOptions, PostgreSQLOptions>?)
Configure connection to use PostgreSQL Npgsql provider, specific dialect, provider-specific options and connection string.
public static DataOptions UsePostgreSQL(this DataOptions options, string connectionString, PostgreSQLVersion dialect = PostgreSQLVersion.AutoDetect, Func<PostgreSQLOptions, PostgreSQLOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringPostgreSQL connection string.
dialect
PostgreSQLVersionPostgreSQL dialect support level.
optionSetter
Func<PostgreSQLOptions, PostgreSQLOptions>Optional PostgreSQLOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UsePostgreSQL(DataOptions, string, Func<PostgreSQLOptions, PostgreSQLOptions>)
Configure connection to use PostgreSQL Npgsql provider, default dialect and connection string.
public static DataOptions UsePostgreSQL(this DataOptions options, string connectionString, Func<PostgreSQLOptions, PostgreSQLOptions> optionSetter)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringPostgreSQL connection string.
optionSetter
Func<PostgreSQLOptions, PostgreSQLOptions>PostgreSQLOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
PostgreSQL dialect will be chosen automatically:
- if AutoDetectProvider (default:
true
) enabled, LinqToDB will query server for version - otherwise v92 will be used as default dialect.
UsePreferApply(DataOptions, bool)
Used to generate CROSS APPLY or OUTER APPLY if possible.
Default value: true
.
public static DataOptions UsePreferApply(this DataOptions options, bool preferApply)
Parameters
options
DataOptionspreferApply
bool
Returns
UsePreferExistsForScalar(DataOptions, bool)
Depending on this option linq2db
generates different SQL for sequence.Contains(value)
.true
- EXISTS (SELECT * FROM sequence WHERE sequence.key = value)
.false
- value IN (SELECT sequence.key FROM sequence)
.
Default value: false
.
public static DataOptions UsePreferExistsForScalar(this DataOptions options, bool preferExistsForScalar)
Parameters
options
DataOptionspreferExistsForScalar
bool
Returns
UsePreloadGroups(DataOptions, bool)
Controls how group data for LINQ queries ended with GroupBy will be loaded:
- if
true
- group data will be loaded together with main query, resulting in 1 + N queries, where N - number of groups; - if
false
- group data will be loaded when you call enumerator for specific group IGrouping<TKey, TElement>. Default value:false
.
public static DataOptions UsePreloadGroups(this DataOptions options, bool preloadGroups)
Parameters
options
DataOptionspreloadGroups
bool
Returns
UseProvider(DataOptions, string)
Defines provider name to use with DataOptions.
public static DataOptions UseProvider(this DataOptions options, string providerName)
Parameters
options
DataOptionsproviderName
string
Returns
UseRandomFactor(DataOptions, double)
The maximum random factor, must not be lesser than 1.
Default value: 1.1
.
public static DataOptions UseRandomFactor(this DataOptions options, double randomFactor)
Parameters
options
DataOptionsrandomFactor
double
Returns
UseRetryPolicy(DataOptions, IRetryPolicy)
Uses retry policy.
public static DataOptions UseRetryPolicy(this DataOptions options, IRetryPolicy retryPolicy)
Parameters
options
DataOptionsretryPolicy
IRetryPolicy
Returns
UseSQLite(DataOptions, Func<SQLiteOptions, SQLiteOptions>?)
Configure connection to use SQLite default provider.
public static DataOptions UseSQLite(this DataOptions options, Func<SQLiteOptions, SQLiteOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<SQLiteOptions, SQLiteOptions>Optional SQLiteOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider will be chosen by probing current folder for provider assembly and if it is not found, default to System.Data.Sqlite
provider.
UseSQLite(DataOptions, string, Func<SQLiteOptions, SQLiteOptions>?)
Configure connection to use SQLite default provider and connection string.
public static DataOptions UseSQLite(this DataOptions options, string connectionString, Func<SQLiteOptions, SQLiteOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSQLite connection string.
optionSetter
Func<SQLiteOptions, SQLiteOptions>Optional SQLiteOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider will be chosen by probing current folder for provider assembly and if it is not found, default to System.Data.Sqlite
provider.
UseSQLiteMicrosoft(DataOptions, Func<SQLiteOptions, SQLiteOptions>?)
Configure connection to use Microsoft.Data.Sqlite
SQLite provider.
public static DataOptions UseSQLiteMicrosoft(this DataOptions options, Func<SQLiteOptions, SQLiteOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<SQLiteOptions, SQLiteOptions>Optional SQLiteOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSQLiteMicrosoft(DataOptions, string, Func<SQLiteOptions, SQLiteOptions>?)
Configure connection to use Microsoft.Data.Sqlite
SQLite provider and connection string.
public static DataOptions UseSQLiteMicrosoft(this DataOptions options, string connectionString, Func<SQLiteOptions, SQLiteOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSQLite connection string.
optionSetter
Func<SQLiteOptions, SQLiteOptions>Optional SQLiteOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSQLiteOfficial(DataOptions, Func<SQLiteOptions, SQLiteOptions>?)
Configure connection to use System.Data.Sqlite
SQLite provider.
public static DataOptions UseSQLiteOfficial(this DataOptions options, Func<SQLiteOptions, SQLiteOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<SQLiteOptions, SQLiteOptions>Optional SQLiteOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSQLiteOfficial(DataOptions, string, Func<SQLiteOptions, SQLiteOptions>?)
Configure connection to use System.Data.Sqlite
SQLite provider and connection string.
public static DataOptions UseSQLiteOfficial(this DataOptions options, string connectionString, Func<SQLiteOptions, SQLiteOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSQLite connection string.
optionSetter
Func<SQLiteOptions, SQLiteOptions>Optional SQLiteOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSapHana(DataOptions, Func<SapHanaOptions, SapHanaOptions>?)
Configure connection to use SAP HANA default provider.
public static DataOptions UseSapHana(this DataOptions options, Func<SapHanaOptions, SapHanaOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<SapHanaOptions, SapHanaOptions>Optional SapHanaOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider will be Sap.Data.Hana
native provider for .NET Framework and .NET Core applications and ODBC provider for .NET STANDARD builds.
UseSapHana(DataOptions, string, Func<SapHanaOptions, SapHanaOptions>?)
Configure connection to use SAP HANA default provider and connection string.
public static DataOptions UseSapHana(this DataOptions options, string connectionString, Func<SapHanaOptions, SapHanaOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSAP HANA connection string.
optionSetter
Func<SapHanaOptions, SapHanaOptions>Optional SapHanaOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
Remarks
Default provider will be Sap.Data.Hana
native provider for .NET Framework and .NET Core applications and ODBC provider for .NET STANDARD builds.
UseSapHanaNative(DataOptions, Func<SapHanaOptions, SapHanaOptions>?)
Configure connection to use native SAP HANA provider.
public static DataOptions UseSapHanaNative(this DataOptions options, Func<SapHanaOptions, SapHanaOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<SapHanaOptions, SapHanaOptions>Optional SapHanaOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSapHanaNative(DataOptions, string, Func<SapHanaOptions, SapHanaOptions>?)
Configure connection to use native SAP HANA provider and connection string.
public static DataOptions UseSapHanaNative(this DataOptions options, string connectionString, Func<SapHanaOptions, SapHanaOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSAP HANA connection string.
optionSetter
Func<SapHanaOptions, SapHanaOptions>Optional SapHanaOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSapHanaODBC(DataOptions, Func<SapHanaOptions, SapHanaOptions>?)
Configure connection to use SAP HANA ODBC provider.
public static DataOptions UseSapHanaODBC(this DataOptions options, Func<SapHanaOptions, SapHanaOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<SapHanaOptions, SapHanaOptions>Optional SapHanaOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSapHanaODBC(DataOptions, string, Func<SapHanaOptions, SapHanaOptions>?)
Configure connection to use SAP HANA ODBC provider and connection string.
public static DataOptions UseSapHanaODBC(this DataOptions options, string connectionString, Func<SapHanaOptions, SapHanaOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSAP HANA connection string.
optionSetter
Func<SapHanaOptions, SapHanaOptions>Optional SapHanaOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSqlCe(DataOptions, Func<SqlCeOptions, SqlCeOptions>?)
Configure connection to use SQL CE provider.
public static DataOptions UseSqlCe(this DataOptions options, Func<SqlCeOptions, SqlCeOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
optionSetter
Func<SqlCeOptions, SqlCeOptions>Optional SqlCeOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSqlCe(DataOptions, string, Func<SqlCeOptions, SqlCeOptions>?)
Configure connection to use SQL CE provider and connection string.
public static DataOptions UseSqlCe(this DataOptions options, string connectionString, Func<SqlCeOptions, SqlCeOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSQL CE connection string.
optionSetter
Func<SqlCeOptions, SqlCeOptions>Optional SqlCeOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSqlServer(DataOptions, SqlServerVersion, SqlServerProvider, Func<SqlServerOptions, SqlServerOptions>?)
Configure connection to use specific SQL Server provider, dialect and provider-specific options.
public static DataOptions UseSqlServer(this DataOptions options, SqlServerVersion dialect = SqlServerVersion.AutoDetect, SqlServerProvider provider = SqlServerProvider.AutoDetect, Func<SqlServerOptions, SqlServerOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
dialect
SqlServerVersionSQL Server dialect support level.
provider
SqlServerProviderSQL Server provider to use.
optionSetter
Func<SqlServerOptions, SqlServerOptions>Optional SqlServerOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseSqlServer(DataOptions, string, SqlServerVersion, SqlServerProvider, Func<SqlServerOptions, SqlServerOptions>?)
Configure connection to use specific SQL Server provider, dialect, connection string and provider-specific options.
public static DataOptions UseSqlServer(this DataOptions options, string connectionString, SqlServerVersion dialect = SqlServerVersion.AutoDetect, SqlServerProvider provider = SqlServerProvider.AutoDetect, Func<SqlServerOptions, SqlServerOptions>? optionSetter = null)
Parameters
options
DataOptionsInstance of DataOptions.
connectionString
stringSQL Server connection string.
dialect
SqlServerVersionSQL Server dialect support level.
provider
SqlServerProviderSQL Server provider to use.
optionSetter
Func<SqlServerOptions, SqlServerOptions>Optional SqlServerOptions configuration callback.
Returns
- DataOptions
The builder instance so calls can be chained.
UseTraceLevel(DataOptions, TraceLevel)
Configure the database to use specified trace level.
public static DataOptions UseTraceLevel(this DataOptions options, TraceLevel traceLevel)
Parameters
options
DataOptionstraceLevel
TraceLevel
Returns
- DataOptions
The builder instance so calls can be chained.
UseTraceMapperExpression(DataOptions, bool)
Enables logging of generated mapping expression to data connection tracing infrastructure.
See TraceSwitch for more details.
Default value: false
.
public static DataOptions UseTraceMapperExpression(this DataOptions options, bool traceMapperExpression)
Parameters
options
DataOptionstraceMapperExpression
bool
Returns
UseTraceWith(DataOptions, Action<string?, string?, TraceLevel>)
Configure the database to use the specified a string trace callback.
public static DataOptions UseTraceWith(this DataOptions options, Action<string?, string?, TraceLevel> write)
Parameters
options
DataOptionswrite
Action<string, string, TraceLevel>Callback, may not be called depending on the trace level.
Returns
- DataOptions
The builder instance so calls can be chained.
UseTracing(DataOptions, Action<TraceInfo>)
Configure the database to use the specified callback for logging or tracing.
public static DataOptions UseTracing(this DataOptions options, Action<TraceInfo> onTrace)
Parameters
options
DataOptionsonTrace
Action<TraceInfo>Callback, may not be called depending on the trace level.
Returns
- DataOptions
The builder instance so calls can be chained.
UseTracing(DataOptions, TraceLevel, Action<TraceInfo>)
Configure the database to use the specified trace level and callback for logging or tracing.
public static DataOptions UseTracing(this DataOptions options, TraceLevel traceLevel, Action<TraceInfo> onTrace)
Parameters
options
DataOptionstraceLevel
TraceLevelTrace level to use.
onTrace
Action<TraceInfo>Callback, may not be called depending on the trace level.
Returns
- DataOptions
The builder instance so calls can be chained.
UseTransaction(DataOptions, IDataProvider, DbTransaction)
Defines data provider and transaction to use with DataOptions.
public static DataOptions UseTransaction(this DataOptions options, IDataProvider dataProvider, DbTransaction transaction)
Parameters
options
DataOptionsdataProvider
IDataProvidertransaction
DbTransaction
Returns
WithAfterConnectionOpened(ConnectionOptions, Action<DbConnection>, Func<DbConnection, CancellationToken, Task>?)
Sets custom actions, executed after connection opened.
public static ConnectionOptions WithAfterConnectionOpened(this ConnectionOptions options, Action<DbConnection> afterConnectionOpened, Func<DbConnection, CancellationToken, Task>? afterConnectionOpenedAsync = null)
Parameters
options
ConnectionOptionsafterConnectionOpened
Action<DbConnection>Action, executed for connection instance after Open() call. Also called after OpenAsync(CancellationToken) call if
afterConnectionOpenedAsync
action is not provided. Accepts connection instance as parameter.afterConnectionOpenedAsync
Func<DbConnection, CancellationToken, Task>Action, executed for connection instance from async execution path after OpenAsync(CancellationToken) call. Accepts connection instance as parameter. If this option is not set,
afterConnectionOpened
synchronous action called. Use this option only if you need to perform async work from action, otherwiseafterConnectionOpened
is sufficient.
Returns
WithBeforeConnectionOpened(ConnectionOptions, Action<DbConnection>, Func<DbConnection, CancellationToken, Task>?)
Sets custom actions, executed before connection opened.
public static ConnectionOptions WithBeforeConnectionOpened(this ConnectionOptions options, Action<DbConnection> afterConnectionOpening, Func<DbConnection, CancellationToken, Task>? afterConnectionOpeningAsync = null)
Parameters
options
ConnectionOptionsafterConnectionOpening
Action<DbConnection>Action, executed before database connection opened. Accepts connection instance as parameter.
afterConnectionOpeningAsync
Func<DbConnection, CancellationToken, Task>Action, executed after database connection opened from async execution path. Accepts connection instance as parameter. If this option is not set,
afterConnectionOpening
synchronous action called. Use this option only if you need to perform async work from action, otherwiseafterConnectionOpening
is sufficient.
Returns
WithBulkCopyTimeout(BulkCopyOptions, int?)
Number of seconds for the operation to complete before it times out.
public static BulkCopyOptions WithBulkCopyTimeout(this BulkCopyOptions options, int? bulkCopyTimeout)
Parameters
options
BulkCopyOptionsbulkCopyTimeout
int?
Returns
WithBulkCopyType(BulkCopyOptions, BulkCopyType)
Bulk copy mode.
public static BulkCopyOptions WithBulkCopyType(this BulkCopyOptions options, BulkCopyType bulkCopyType)
Parameters
options
BulkCopyOptionsbulkCopyType
BulkCopyType
Returns
WithCacheSlidingExpiration(LinqOptions, TimeSpan?)
Specifies timeout when query will be evicted from cache since last execution of query. Default value is 1 hour.
public static LinqOptions WithCacheSlidingExpiration(this LinqOptions options, TimeSpan? cacheSlidingExpiration)
Parameters
options
LinqOptionscacheSlidingExpiration
TimeSpan?
Returns
WithCheckConstraints(BulkCopyOptions, bool?)
Checks constraints while data is being inserted.
public static BulkCopyOptions WithCheckConstraints(this BulkCopyOptions options, bool? checkConstraints)
Parameters
options
BulkCopyOptionscheckConstraints
bool?
Returns
WithCoefficient(RetryPolicyOptions, TimeSpan)
The coefficient for the exponential function used to compute the delay between retries, must be nonnegative. Default value: 1 second.
public static RetryPolicyOptions WithCoefficient(this RetryPolicyOptions options, TimeSpan coefficient)
Parameters
options
RetryPolicyOptionscoefficient
TimeSpan
Returns
WithCompareNullsAsValues(LinqOptions, bool)
If set to true nullable fields would be checked for IS NULL in Equal/NotEqual comparisons.
This affects: Equal, NotEqual, Not Contains
Default value: true
.
public static LinqOptions WithCompareNullsAsValues(this LinqOptions options, bool compareNullsAsValues)
Parameters
options
LinqOptionscompareNullsAsValues
bool
Returns
Examples
public class MyEntity
{
public int? Value;
}
db.MyEntity.Where(e => e.Value != 10)
from e1 in db.MyEntity
join e2 in db.MyEntity on e1.Value equals e2.Value
select e1
var filter = new [] {1, 2, 3};
db.MyEntity.Where(e => ! filter.Contains(e.Value))
Would be converted to next queries:
SELECT Value FROM MyEntity WHERE Value IS NULL OR Value != 10
SELECT e1.Value
FROM MyEntity e1
INNER JOIN MyEntity e2 ON e1.Value = e2.Value OR (e1.Value IS NULL AND e2.Value IS NULL)
SELECT Value FROM MyEntity WHERE Value IS NULL OR NOT Value IN (1, 2, 3)
WithConfigurationString(ConnectionOptions, string?)
Sets ConfigurationString option.
public static ConnectionOptions WithConfigurationString(this ConnectionOptions options, string? configurationString)
Parameters
options
ConnectionOptionsconfigurationString
string
Returns
WithConnectionFactory(ConnectionOptions, Func<DataOptions, DbConnection>)
Sets ConnectionFactory option.
public static ConnectionOptions WithConnectionFactory(this ConnectionOptions options, Func<DataOptions, DbConnection> connectionFactory)
Parameters
options
ConnectionOptionsconnectionFactory
Func<DataOptions, DbConnection>
Returns
WithConnectionString(ConnectionOptions, string?)
Sets ConnectionString option.
public static ConnectionOptions WithConnectionString(this ConnectionOptions options, string? connectionString)
Parameters
options
ConnectionOptionsconnectionString
string
Returns
WithDataProvider(ConnectionOptions, IDataProvider?)
Sets DataProvider option.
public static ConnectionOptions WithDataProvider(this ConnectionOptions options, IDataProvider? dataProvider)
Parameters
options
ConnectionOptionsdataProvider
IDataProvider
Returns
WithDataProviderFactory(ConnectionOptions, Func<ConnectionOptions, IDataProvider>)
Sets DataProviderFactory option.
public static ConnectionOptions WithDataProviderFactory(this ConnectionOptions options, Func<ConnectionOptions, IDataProvider> dataProviderFactory)
Parameters
options
ConnectionOptionsdataProviderFactory
Func<ConnectionOptions, IDataProvider>
Returns
WithDatabaseName(BulkCopyOptions, string?)
Gets or sets explicit name of target database instead of one, configured for copied entity in mapping schema. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
public static BulkCopyOptions WithDatabaseName(this BulkCopyOptions options, string? databaseName)
Parameters
options
BulkCopyOptionsdatabaseName
string
Returns
WithDbConnection(ConnectionOptions, DbConnection?)
Sets DbConnection option.
public static ConnectionOptions WithDbConnection(this ConnectionOptions options, DbConnection? connection)
Parameters
options
ConnectionOptionsconnection
DbConnection
Returns
WithDbTransaction(ConnectionOptions, DbTransaction)
Sets DbTransaction option.
public static ConnectionOptions WithDbTransaction(this ConnectionOptions options, DbTransaction transaction)
Parameters
options
ConnectionOptionstransaction
DbTransaction
Returns
WithDisableQueryCache(LinqOptions, bool)
Used to disable LINQ expressions caching for queries. This cache reduces time, required for query parsing but have several side-effects:
- cached LINQ expressions could contain references to external objects as parameters, which could lead to memory leaks if those objects are not used anymore by other code - cache access synchronization could lead to bigger latencies than it saves. Default value:false
.
It is not recommended to enable this option as it could lead to severe slowdown. Better approach will be
to call ClearCache() method to cleanup cache after queries, that produce severe memory leaks you need to fix.
More details.
public static LinqOptions WithDisableQueryCache(this LinqOptions options, bool disableQueryCache)
Parameters
options
LinqOptionsdisableQueryCache
bool
Returns
WithDisposeConnection(ConnectionOptions, bool)
Sets DisposeConnection option.
public static ConnectionOptions WithDisposeConnection(this ConnectionOptions options, bool disposeConnection)
Parameters
options
ConnectionOptionsdisposeConnection
bool
Returns
WithDoNotClearOrderBys(LinqOptions, bool)
Controls behavior, when LINQ query chain contains multiple OrderBy<TSource, TKey>(IQueryable<TSource>, Expression<Func<TSource, TKey>>) or OrderByDescending<TSource, TKey>(IQueryable<TSource>, Expression<Func<TSource, TKey>>) calls:
- if
true
- non-first OrderBy* call will be treated as ThenBy* call; - if
false
- OrderBy* call will discard sort specifications, added by previous OrderBy* and ThenBy* calls. Default value:false
.
public static LinqOptions WithDoNotClearOrderBys(this LinqOptions options, bool doNotClearOrderBys)
Parameters
options
LinqOptionsdoNotClearOrderBys
bool
Returns
WithEnableConstantExpressionInOrderBy(SqlOptions, bool)
If true
, linq2db will allow any constant expressions in ORDER BY clause.
Default value: false
.
public static SqlOptions WithEnableConstantExpressionInOrderBy(this SqlOptions options, bool enableConstantExpressionInOrderBy)
Parameters
options
SqlOptionsenableConstantExpressionInOrderBy
bool
Returns
WithEnableContextSchemaEdit(LinqOptions, bool)
If true
, user could add new mappings to context mapping schems (MappingSchema).
Otherwise, LinqToDBException will be generated on locked mapping schema edit attempt.
It is not recommended to enable this option as it has performance implications.
Proper approach is to create single MappingSchema instance once, configure mappings for it and use this MappingSchema instance for all context instances.
public static LinqOptions WithEnableContextSchemaEdit(this LinqOptions options, bool enableContextSchemaEdit)
Parameters
options
LinqOptionsenableContextSchemaEdit
bool
Returns
WithExponentialBase(RetryPolicyOptions, double)
The base for the exponential function used to compute the delay between retries, must be positive.
Default value: 2
.
public static RetryPolicyOptions WithExponentialBase(this RetryPolicyOptions options, double exponentialBase)
Parameters
options
RetryPolicyOptionsexponentialBase
double
Returns
WithFactory(RetryPolicyOptions, Func<DataConnection, IRetryPolicy?>?)
Retry policy factory method, used to create retry policy for new DataConnection instance. If factory method is not set, retry policy is not used. Not set by default.
public static RetryPolicyOptions WithFactory(this RetryPolicyOptions options, Func<DataConnection, IRetryPolicy?>? factory)
Parameters
options
RetryPolicyOptionsfactory
Func<DataConnection, IRetryPolicy>
Returns
WithFireTriggers(BulkCopyOptions, bool?)
When specified, causes the server to fire the insert triggers for the rows being inserted into the database.
public static BulkCopyOptions WithFireTriggers(this BulkCopyOptions options, bool? fireTriggers)
Parameters
options
BulkCopyOptionsfireTriggers
bool?
Returns
WithGenerateExpressionTest(LinqOptions, bool)
Enables generation of test class for each LINQ query, executed while this option is enabled.
This option could be useful for issue reporting, when you need to provide reproducible case.
Test file will be placed to linq2db
subfolder of temp folder and exact file path will be logged
to data connection tracing infrastructure.
See TraceSwitch for more details.
Default value: false
.
public static LinqOptions WithGenerateExpressionTest(this LinqOptions options, bool generateExpressionTest)
Parameters
options
LinqOptionsgenerateExpressionTest
bool
Returns
WithGenerateFinalAliases(SqlOptions, bool)
Indicates whether SQL Builder should generate aliases for final projection. It is not required for correct query processing but simplifies SQL analysis.
Default value: false
.
var query = from child in db.Child
select new
{
TrackId = child.ChildID,
};
When property is true
SELECT
[child].[ChildID] as [TrackId]
FROM
[Child] [child]
Otherwise alias will be removed
SELECT
[child].[ChildID]
FROM
[Child] [child]
public static SqlOptions WithGenerateFinalAliases(this SqlOptions options, bool generateFinalAliases)
Parameters
options
SqlOptionsgenerateFinalAliases
bool
Returns
WithGuardGrouping(LinqOptions, bool)
Controls behavior of LINQ query, which ends with GroupBy call.
- if
true
- LinqToDBException will be thrown for such queries; - if
false
- behavior is controlled by UsePreloadGroups(DataOptions, bool) option. Default value:true
.
public static LinqOptions WithGuardGrouping(this LinqOptions options, bool guardGrouping)
Parameters
options
LinqOptionsguardGrouping
bool
Returns
Remarks
WithIgnoreEmptyUpdate(LinqOptions, bool)
Controls behavior of linq2db
when there is no updateable fields in Update query:
- if
true
- query not executed and Update operation returns 0 as number of affected records; - if
false
- LinqToDBException will be thrown. Default value:false
.
public static LinqOptions WithIgnoreEmptyUpdate(LinqOptions options, bool ignoreEmptyUpdate)
Parameters
options
LinqOptionsignoreEmptyUpdate
bool
Returns
WithKeepDistinctOrdered(LinqOptions, bool)
Allows SQL generation to automatically transform
SELECT DISTINCT value FROM Table ORDER BY date
Into GROUP BY equivalent if syntax is not supported
Default value: true
.
public static LinqOptions WithKeepDistinctOrdered(this LinqOptions options, bool keepDistinctOrdered)
Parameters
options
LinqOptionskeepDistinctOrdered
bool
Returns
WithKeepIdentity(BulkCopyOptions, bool?)
If this option set to true, bulk copy will use values of columns, marked with IsIdentity flag. SkipOnInsert flag in this case will be ignored. Otherwise, those columns will be skipped and values will be generated by server. Not compatible with RowByRow mode.
public static BulkCopyOptions WithKeepIdentity(this BulkCopyOptions options, bool? keepIdentity)
Parameters
options
BulkCopyOptionskeepIdentity
bool?
Returns
WithKeepNulls(BulkCopyOptions, bool?)
Preserves null values in the destination table regardless of the settings for default values.
public static BulkCopyOptions WithKeepNulls(this BulkCopyOptions options, bool? keepNulls)
Parameters
options
BulkCopyOptionskeepNulls
bool?
Returns
WithMappingSchema(ConnectionOptions, MappingSchema)
Sets MappingSchema option.
public static ConnectionOptions WithMappingSchema(this ConnectionOptions options, MappingSchema mappingSchema)
Parameters
options
ConnectionOptionsmappingSchema
MappingSchema
Returns
WithMaxBatchSize(BulkCopyOptions, int?)
Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server. Returns an integer value or zero if no value has been set.
public static BulkCopyOptions WithMaxBatchSize(this BulkCopyOptions options, int? maxBatchSize)
Parameters
options
BulkCopyOptionsmaxBatchSize
int?
Returns
WithMaxDegreeOfParallelism(BulkCopyOptions, int?)
Implemented only by ClickHouse.Client provider. Defines number of connections, used for parallel insert in ProviderSpecific mode.
public static BulkCopyOptions WithMaxDegreeOfParallelism(this BulkCopyOptions options, int? maxDegreeOfParallelism)
Parameters
options
BulkCopyOptionsmaxDegreeOfParallelism
int?
Returns
WithMaxDelay(RetryPolicyOptions, TimeSpan)
The maximum time delay between retries, must be nonnegative. Default value: 30 seconds.
public static RetryPolicyOptions WithMaxDelay(this RetryPolicyOptions options, TimeSpan maxDelay)
Parameters
options
RetryPolicyOptionsmaxDelay
TimeSpan
Returns
WithMaxParametersForBatch(BulkCopyOptions, int?)
If set, will override the Maximum parameters per batch statement from MaxParameters.
public static BulkCopyOptions WithMaxParametersForBatch(this BulkCopyOptions options, int? maxParametersForBatch)
Parameters
options
BulkCopyOptionsmaxParametersForBatch
int?
Returns
WithMaxRetryCount(RetryPolicyOptions, int)
The number of retry attempts.
Default value: 5
.
public static RetryPolicyOptions WithMaxRetryCount(this RetryPolicyOptions options, int maxRetryCount)
Parameters
options
RetryPolicyOptionsmaxRetryCount
int
Returns
WithNotifyAfter(BulkCopyOptions, int)
Gets or sets counter after how many copied records RowsCopiedCallback should be called. E.g. if you set it to 10, callback will be called after each 10 copied records. To disable callback, set this option to 0 (default value).
public static BulkCopyOptions WithNotifyAfter(this BulkCopyOptions options, int notifyAfter)
Parameters
options
BulkCopyOptionsnotifyAfter
int
Returns
WithOnEntityDescriptorCreated(ConnectionOptions, Action<MappingSchema, IEntityChangeDescriptor>)
Sets OnEntityDescriptorCreated option.
public static ConnectionOptions WithOnEntityDescriptorCreated(this ConnectionOptions options, Action<MappingSchema, IEntityChangeDescriptor> onEntityDescriptorCreated)
Parameters
options
ConnectionOptionsonEntityDescriptorCreated
Action<MappingSchema, IEntityChangeDescriptor>
Returns
WithOnTrace(QueryTraceOptions, Action<TraceInfo>)
Configure the database to use the specified callback for logging or tracing.
public static QueryTraceOptions WithOnTrace(this QueryTraceOptions options, Action<TraceInfo> onTrace)
Parameters
options
QueryTraceOptionsonTrace
Action<TraceInfo>Callback, may not be called depending on the trace level.
Returns
- QueryTraceOptions
The builder instance so calls can be chained.
WithOptimizeJoins(LinqOptions, bool)
If enabled, linq2db
will try to reduce number of generated SQL JOINs for LINQ query.
Attempted optimizations:
- removes duplicate joins by unique target table key;
- removes self-joins by unique key;
- removes left joins if joined table is not used in query.
Default value:
true
.
public static LinqOptions WithOptimizeJoins(this LinqOptions options, bool optimizeJoins)
Parameters
options
LinqOptionsoptimizeJoins
bool
Returns
WithParameterizeTakeSkip(LinqOptions, bool)
Enables Take/Skip parameterization.
Default value: true
.
public static LinqOptions WithParameterizeTakeSkip(this LinqOptions options, bool parameterizeTakeSkip)
Parameters
options
LinqOptionsparameterizeTakeSkip
bool
Returns
WithPreferApply(LinqOptions, bool)
Used to generate CROSS APPLY or OUTER APPLY if possible.
Default value: true
.
public static LinqOptions WithPreferApply(this LinqOptions options, bool preferApply)
Parameters
options
LinqOptionspreferApply
bool
Returns
WithPreferExistsForScalar(LinqOptions, bool)
Depending on this option linq2db
generates different SQL for sequence.Contains(value)
.true
- EXISTS (SELECT * FROM sequence WHERE sequence.key = value)
.false
- value IN (SELECT sequence.key FROM sequence)
.
Default value: false
.
public static LinqOptions WithPreferExistsForScalar(this LinqOptions options, bool preferExistsForScalar)
Parameters
options
LinqOptionspreferExistsForScalar
bool
Returns
WithPreloadGroups(LinqOptions, bool)
Controls how group data for LINQ queries ended with GroupBy will be loaded:
- if
true
- group data will be loaded together with main query, resulting in 1 + N queries, where N - number of groups; - if
false
- group data will be loaded when you call enumerator for specific group IGrouping<TKey, TElement>. Default value:false
.
public static LinqOptions WithPreloadGroups(this LinqOptions options, bool preloadGroups)
Parameters
options
LinqOptionspreloadGroups
bool
Returns
WithProviderName(ConnectionOptions, string)
Sets ProviderName option.
public static ConnectionOptions WithProviderName(this ConnectionOptions options, string providerName)
Parameters
options
ConnectionOptionsproviderName
string
Returns
WithRandomFactor(RetryPolicyOptions, double)
The maximum random factor, must not be lesser than 1.
Default value: 1.1
.
public static RetryPolicyOptions WithRandomFactor(this RetryPolicyOptions options, double randomFactor)
Parameters
options
RetryPolicyOptionsrandomFactor
double
Returns
WithRetryPolicy(RetryPolicyOptions, IRetryPolicy)
Uses retry policy
public static RetryPolicyOptions WithRetryPolicy(this RetryPolicyOptions options, IRetryPolicy retryPolicy)
Parameters
options
RetryPolicyOptionsretryPolicy
IRetryPolicy
Returns
WithRowsCopiedCallback(BulkCopyOptions, Action<BulkCopyRowsCopied>?)
Gets or sets callback method that will be called by BulkCopy operation after each NotifyAfter rows copied. This callback will not be used if NotifyAfter set to 0.
public static BulkCopyOptions WithRowsCopiedCallback(this BulkCopyOptions options, Action<BulkCopyRowsCopied>? rowsCopiedCallback)
Parameters
options
BulkCopyOptionsrowsCopiedCallback
Action<BulkCopyRowsCopied>
Returns
WithSchemaName(BulkCopyOptions, string?)
Gets or sets explicit name of target schema/owner instead of one, configured for copied entity in mapping schema. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
public static BulkCopyOptions WithSchemaName(this BulkCopyOptions options, string? schemaName)
Parameters
options
BulkCopyOptionsschemaName
string
Returns
WithServerName(BulkCopyOptions, string?)
Gets or sets explicit name of target server instead of one, configured for copied entity in mapping schema. See ServerName<T>(ITable<T>, string?) method for support information per provider. Also note that it is not supported by provider-specific insert method.
public static BulkCopyOptions WithServerName(this BulkCopyOptions options, string? serverName)
Parameters
options
BulkCopyOptionsserverName
string
Returns
WithTableLock(BulkCopyOptions, bool?)
Obtains a bulk update lock for the duration of the bulk copy operation.
public static BulkCopyOptions WithTableLock(this BulkCopyOptions options, bool? tableLock)
Parameters
options
BulkCopyOptionstableLock
bool?
Returns
WithTableName(BulkCopyOptions, string?)
Gets or sets explicit name of target table instead of one, configured for copied entity in mapping schema.
public static BulkCopyOptions WithTableName(this BulkCopyOptions options, string? tableName)
Parameters
options
BulkCopyOptionstableName
string
Returns
WithTableOptions(BulkCopyOptions, TableOptions)
Gets or sets TableOptions flags overrides instead of configured for copied entity in mapping schema. See IsTemporary<T>(ITable<T>, bool) method for support information per provider.
public static BulkCopyOptions WithTableOptions(this BulkCopyOptions options, TableOptions tableOptions)
Parameters
options
BulkCopyOptionstableOptions
TableOptions
Returns
WithTraceLevel(QueryTraceOptions, TraceLevel)
Configure the database to use specified trace level.
public static QueryTraceOptions WithTraceLevel(this QueryTraceOptions options, TraceLevel traceLevel)
Parameters
options
QueryTraceOptionstraceLevel
TraceLevel
Returns
- QueryTraceOptions
The builder instance so calls can be chained.
WithTraceMapperExpression(LinqOptions, bool)
Enables logging of generated mapping expression to data connection tracing infrastructure.
See TraceSwitch for more details.
Default value: false
.
public static LinqOptions WithTraceMapperExpression(this LinqOptions options, bool traceMapperExpression)
Parameters
options
LinqOptionstraceMapperExpression
bool
Returns
WithUseInternalTransaction(BulkCopyOptions, bool?)
When specified, each batch of the bulk-copy operation will occur within a transaction.
public static BulkCopyOptions WithUseInternalTransaction(this BulkCopyOptions options, bool? useInternalTransaction)
Parameters
options
BulkCopyOptionsuseInternalTransaction
bool?
Returns
WithUseParameters(BulkCopyOptions, bool)
Gets or sets whether to Always use Parameters for MultipleRowsCopy. Default is false. If True, provider's override for MaxParameters will be used to determine the maximum number of rows per insert, Unless overridden by MaxParametersForBatch.
public static BulkCopyOptions WithUseParameters(this BulkCopyOptions options, bool useParameters)
Parameters
options
BulkCopyOptionsuseParameters
bool
Returns
WithWithoutSession(BulkCopyOptions, bool)
Implemented only by ClickHouse.Client provider. When set, provider-specific bulk copy will use session-less connection even if called over connection with session. Note that session-less connections cannot be used with session-bound functionality like temporary tables.
public static BulkCopyOptions WithWithoutSession(this BulkCopyOptions options, bool withoutSession)
Parameters
options
BulkCopyOptionswithoutSession
bool
Returns
WithWriteTrace(QueryTraceOptions, Action<string?, string?, TraceLevel>)
Configure the database to use the specified a string trace callback.
public static QueryTraceOptions WithWriteTrace(this QueryTraceOptions options, Action<string?, string?, TraceLevel> write)
Parameters
options
QueryTraceOptionswrite
Action<string, string, TraceLevel>Callback, may not be called depending on the trace level.
Returns
- QueryTraceOptions
The builder instance so calls can be chained.