linq2db by Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko

<PackageReference Include="linq2db" Version="5.3.0" />

.NET API 4,394,496 bytes

 DataOptionsExtensions

public static class DataOptionsExtensions
Set of extensions for DataOptions.
public static DataOptions RemoveInterceptor(this DataOptions options, IInterceptor interceptor)

Removes IInterceptor instance from the context.

public static DataOptions UseAccess(this DataOptions options, string connectionString, Func<AccessOptions, AccessOptions> optionSetter = null)

Configure connection to use Access default provider and connection string.

public static DataOptions UseAccessOdbc(this DataOptions options, Func<AccessOptions, AccessOptions> optionSetter = null)

Configure connection to use Access ODBC provider.

public static DataOptions UseAccessOdbc(this DataOptions options, string connectionString, Func<AccessOptions, AccessOptions> optionSetter = null)

Configure connection to use Access ODBC provider and connection string.

public static DataOptions UseAccessOleDb(this DataOptions options, Func<AccessOptions, AccessOptions> optionSetter = null)

Configure connection to use Access OleDb provider.

public static DataOptions UseAccessOleDb(this DataOptions options, string connectionString, Func<AccessOptions, AccessOptions> optionSetter = null)

Configure connection to use Access OleDb provider and connection string.

public static DataOptions UseAfterConnectionOpened(this DataOptions options, Action<DbConnection> afterConnectionOpened, Func<DbConnection, CancellationToken, Task> afterConnectionOpenedAsync = null)

Sets custom actions, executed after connection opened.

public static DataOptions UseAse(this DataOptions options, Func<SybaseOptions, SybaseOptions> optionSetter = null)

Configure connection to use SAP/Sybase ASE default provider.

public static DataOptions UseAse(this DataOptions options, string connectionString, Func<SybaseOptions, SybaseOptions> optionSetter = null)

Configure connection to use SAP/Sybase ASE default provider and connection string.

public static DataOptions UseBeforeConnectionOpened(this DataOptions options, Action<DbConnection> afterConnectionOpening, Func<DbConnection, CancellationToken, Task> afterConnectionOpeningAsync = null)

Sets custom actions, executed before connection opened.

public static DataOptions UseBulkCopyCheckConstraints(this DataOptions options, bool? checkConstraints)

Enables database constrains enforcement during bulk copy operation. Supported with ProviderSpecific bulk copy mode for following databases: OracleSQL ServerSAP/Sybase ASE

public static DataOptions UseBulkCopyDatabaseName(this DataOptions options, string databaseName)

Gets or sets explicit name of target database instead of one, configured for copied entity in mapping schema. See DatabaseName<T> method for support information per provider.

public static DataOptions UseBulkCopyFireTriggers(this DataOptions options, bool? fireTriggers)

Enables insert triggers during bulk copy operation. Supported with ProviderSpecific bulk copy mode for following databases: OracleSQL ServerSAP/Sybase ASE

public static DataOptions UseBulkCopyKeepIdentity(this DataOptions options, bool? keepIdentity)

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 UseBulkCopyKeepNulls(this DataOptions options, bool? keepNulls)

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 ServerSAP/Sybase ASE

public static DataOptions UseBulkCopyMaxBatchSize(this DataOptions options, int? maxBatchSize)

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 UseBulkCopyMaxDegreeOfParallelism(this DataOptions options, int? maxDegreeOfParallelism)

Implemented only by ClickHouse.Client provider. Defines number of connections, used for parallel insert in ProviderSpecific mode.

public static DataOptions UseBulkCopyMaxParametersForBatch(this DataOptions options, int? maxParametersForBatch)

If set, will override the Maximum parameters per batch statement from MaxParameters.

public static DataOptions UseBulkCopyNotifyAfter(this DataOptions options, int notifyAfter)

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 UseBulkCopyRowsCopiedCallback(this DataOptions options, Action<BulkCopyRowsCopied> rowsCopiedCallback)

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 UseBulkCopySchemaName(this DataOptions options, string schemaName)

Gets or sets explicit name of target schema/owner instead of one, configured for copied entity in mapping schema. See SchemaName<T> method for support information per provider.

public static DataOptions UseBulkCopyServerName(this DataOptions options, string serverName)

Gets or sets explicit name of target server instead of one, configured for copied entity in mapping schema. See ServerName<T> method for support information per provider. Also note that it is not supported by provider-specific insert method.

public static DataOptions UseBulkCopyTableLock(this DataOptions options, bool? tableLock)

Applies table lock during bulk copy operation. Supported with ProviderSpecific bulk copy mode for following databases: DB2Informix (using DB2 provider)SQL ServerSAP/Sybase ASE

public static DataOptions UseBulkCopyTableName(this DataOptions options, string tableName)

Gets or sets explicit name of target table instead of one, configured for copied entity in mapping schema.

public static DataOptions UseBulkCopyTableOptions(this DataOptions options, TableOptions tableOptions)

Gets or sets TableOptions flags overrides instead of configured for copied entity in mapping schema. See IsTemporary<T> method for support information per provider.

public static DataOptions UseBulkCopyTimeout(this DataOptions options, int? bulkCopyTimeout)

Number of seconds for the operation to complete before it times out.

public static DataOptions UseBulkCopyType(this DataOptions options, BulkCopyType bulkCopyType)

Specify bulk copy implementation type.

public static DataOptions UseBulkCopyUseInternalTransaction(this DataOptions options, bool? useInternalTransaction)

Enables automatic transaction creation during bulk copy operation. Supported with ProviderSpecific bulk copy mode for following databases: OracleSQL ServerSAP/Sybase ASE

public static DataOptions UseBulkCopyUseParameters(this DataOptions options, bool useParameters)

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 UseBulkCopyWithoutSession(this DataOptions options, bool withoutSession)

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 UseCacheSlidingExpiration(this DataOptions options, TimeSpan? cacheSlidingExpiration)

Specifies timeout when query will be evicted from cache since last execution of query. Default value is 1 hour.

public static DataOptions UseClickHouse(this DataOptions options, ClickHouseProvider provider, Func<ClickHouseOptions, ClickHouseOptions> optionSetter = null)

Configure connection to use UseClickHouse provider.

public static DataOptions UseClickHouse(this DataOptions options, ClickHouseProvider provider, string connectionString, Func<ClickHouseOptions, ClickHouseOptions> optionSetter = null)

Configure connection to use UseClickHouse provider and connection string.

public static DataOptions UseCoefficient(this DataOptions options, TimeSpan coefficient)

The coefficient for the exponential function used to compute the delay between retries, must be nonnegative. Default value: 1 second.

public static DataOptions UseCompareNullsAsValues(this DataOptions options, bool compareNullsAsValues)

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 UseConfiguration(this DataOptions options, string configurationString)

Defines configuration sting to use with DataOptions.

public static DataOptions UseConfiguration(this DataOptions options, string configurationString, MappingSchema mappingSchema)

Defines configuration sting and MappingSchema to use with DataOptions.

public static DataOptions UseConfigurationString(this DataOptions options, string configurationString)

Defines configuration sting to use with DataOptions.

public static DataOptions UseConfigurationString(this DataOptions options, string configurationString, MappingSchema mappingSchema)

Defines configuration sting and MappingSchema to use with DataOptions.

public static DataOptions UseConnection(this DataOptions options, DbConnection connection)

Defines DbConnection to use with DataOptions.

public static DataOptions UseConnection(this DataOptions options, IDataProvider dataProvider, DbConnection connection)

Defines data provider and DbConnection to use with DataOptions.

public static DataOptions UseConnection(this DataOptions options, IDataProvider dataProvider, DbConnection connection, bool disposeConnection)

Defines data provider and DbConnection to use with DataOptions.

public static DataOptions UseConnectionFactory(this DataOptions options, Func<DataOptions, DbConnection> connectionFactory)

Defines connection factory to use with DataOptions.

public static DataOptions UseConnectionFactory(this DataOptions options, IDataProvider dataProvider, Func<DataOptions, DbConnection> connectionFactory)

Defines data provider and connection factory to use with DataOptions.

public static DataOptions UseConnectionString(this DataOptions options, string providerName, string connectionString)

Defines provider name and connection sting to use with DataOptions.

public static DataOptions UseConnectionString(this DataOptions options, IDataProvider dataProvider, string connectionString)

Defines data provider and connection sting to use with DataOptions.

public static DataOptions UseConnectionString(this DataOptions options, string connectionString)

Defines connection sting to use with DataOptions.

public static DataOptions UseDataProvider(this DataOptions options, IDataProvider dataProvider)

Defines data provider to use with DataOptions.

public static DataOptions UseDataProviderFactory(this DataOptions options, Func<ConnectionOptions, IDataProvider> dataProviderFactory)

Sets DataProviderFactory option.

public static DataOptions UseDB2(this DataOptions options, string connectionString, Func<DB2Options, DB2Options> optionSetter = null)

Configure connection to use DB2 default provider and connection string.

public static DataOptions UseDB2(this DataOptions options, DB2Version version, Func<DB2Options, DB2Options> optionSetter = null)

Configure connection to use specific DB2 provider.

public static DataOptions UseDB2(this DataOptions options, string connectionString, DB2Version version, Func<DB2Options, DB2Options> optionSetter = null)

Configure connection to use specific DB2 provider and connection string.

Uses default retry policy factory.

public static DataOptions UseDisableQueryCache(this DataOptions options, bool disableQueryCache)

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 UseDoNotClearOrderBys(this DataOptions options, bool doNotClearOrderBys)

Controls behavior, when LINQ query chain contains multiple OrderBy<T, U> or OrderByDescending<T, U> 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 UseEnableContextSchemaEdit(this DataOptions options, bool enableContextSchemaEdit)

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 UseExponentialBase(this DataOptions options, double exponentialBase)

The base for the exponential function used to compute the delay between retries, must be positive. Default value: 2.

public static DataOptions UseFactory(this DataOptions options, Func<DataConnection, IRetryPolicy> factory)

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 UseFirebird(this DataOptions options, Func<FirebirdOptions, FirebirdOptions> optionSetter = null)

Configure connection to use Firebird provider.

public static DataOptions UseFirebird(this DataOptions options, string connectionString, Func<FirebirdOptions, FirebirdOptions> optionSetter = null)

Configure connection to use Firebird provider and connection string.

public static DataOptions UseGenerateExpressionTest(this DataOptions options, bool generateExpressionTest)

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 UseGuardGrouping(this DataOptions options, bool guardGrouping)

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 option. Default value: true.

public static DataOptions UseIgnoreEmptyUpdate(DataOptions options, bool ignoreEmptyUpdate)

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 UseInformix(this DataOptions options, Func<InformixOptions, InformixOptions> optionSetter = null)

Configure connection to use Informix default provider.

public static DataOptions UseInformix(this DataOptions options, string connectionString, Func<InformixOptions, InformixOptions> optionSetter = null)

Configure connection to use Informix default provider and connection string.

public static DataOptions UseInterceptor(this DataOptions options, IInterceptor interceptor)

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 UseInterceptors(this DataOptions options, IEnumerable<IInterceptor> interceptors)

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, IInterceptor[] interceptors)

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 UseKeepDistinctOrdered(this DataOptions options, bool keepDistinctOrdered)

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 UseMappingSchema(this DataOptions options, MappingSchema mappingSchema)

Defines mapping schema to use with DataOptions.

public static DataOptions UseMaxDelay(this DataOptions options, TimeSpan defaultMaxDelay)

The maximum time delay between retries, must be nonnegative. Default value: 30 seconds.

public static DataOptions UseMaxRetryCount(this DataOptions options, int maxRetryCount)

The number of retry attempts. Default value: 5.

public static DataOptions UseMySql(this DataOptions options, Func<MySqlOptions, MySqlOptions> optionSetter = null)

Configure connection to use MySql default provider.

public static DataOptions UseMySql(this DataOptions options, string connectionString, Func<MySqlOptions, MySqlOptions> optionSetter = null)

Configure connection to use MySql default provider and connection string.

public static DataOptions UseMySqlConnector(this DataOptions options, Func<MySqlOptions, MySqlOptions> optionSetter = null)

Configure connection to use MySqlConnector MySql provider.

public static DataOptions UseMySqlConnector(this DataOptions options, string connectionString, Func<MySqlOptions, MySqlOptions> optionSetter = null)

Configure connection to use MySqlConnector MySql provider and connection string.

public static DataOptions UseMySqlData(this DataOptions options, Func<MySqlOptions, MySqlOptions> optionSetter = null)

Configure connection to use MySql.Data MySql provider.

public static DataOptions UseMySqlData(this DataOptions options, string connectionString, Func<MySqlOptions, MySqlOptions> optionSetter = null)

Configure connection to use MySql.Data MySql provider and connection string.

public static DataOptions UseOnEntityDescriptorCreated(this DataOptions options, Action<MappingSchema, IEntityChangeDescriptor> onEntityDescriptorCreated)

Defines entity descriptor creation callback to use with DataOptions.

public static DataOptions UseOptimizeJoins(this DataOptions options, bool optimizeJoins)

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 UseOracle(this DataOptions options, string connectionString, Func<OracleOptions, OracleOptions> optionSetter = null)

Configure connection to use Oracle default provider, specific dialect and connection string.

public static DataOptions UseOracle(this DataOptions options, OracleVersion dialect, OracleProvider provider, Func<OracleOptions, OracleOptions> optionSetter = null)

Configure connection to use specific Oracle provider, dialect and provider-specific options.

public static DataOptions UseOracle(this DataOptions options, string connectionString, OracleVersion dialect, OracleProvider provider, Func<OracleOptions, OracleOptions> optionSetter = null)

Configure connection to use specific Oracle provider, dialect and connection string.

public static DataOptions UseOracle(this DataOptions options, string connectionString, OracleProvider provider, Func<OracleOptions, OracleOptions> optionSetter = null)

Configure connection to use specific Oracle provider and connection string.

public static DataOptions UseParameterizeTakeSkip(this DataOptions options, bool parameterizeTakeSkip)

Enables Take/Skip parameterization. Default value: true.

public static DataOptions UsePostgreSQL(this DataOptions options, string connectionString, Func<PostgreSQLOptions, PostgreSQLOptions> optionSetter)

Configure connection to use PostgreSQL Npgsql provider, default dialect and connection string.

public static DataOptions UsePostgreSQL(this DataOptions options, PostgreSQLVersion dialect = 0, Func<PostgreSQLOptions, PostgreSQLOptions> optionSetter = null)

Configure connection to use PostgreSQL Npgsql provider, specific dialect and provider-specific options.

public static DataOptions UsePostgreSQL(this DataOptions options, string connectionString, PostgreSQLVersion dialect = 0, Func<PostgreSQLOptions, PostgreSQLOptions> optionSetter = null)

Configure connection to use PostgreSQL Npgsql provider, specific dialect, provider-specific options and connection string.

public static DataOptions UsePreferApply(this DataOptions options, bool preferApply)

Used to generate CROSS APPLY or OUTER APPLY if possible. Default value: true.

public static DataOptions UsePreferExistsForScalar(this DataOptions options, bool preferExistsForScalar)

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 UsePreloadGroups(this DataOptions options, bool preloadGroups)

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<T, U>. Default value: false.

public static DataOptions UseProvider(this DataOptions options, string providerName)

Defines provider name to use with DataOptions.

public static DataOptions UseRandomFactor(this DataOptions options, double randomFactor)

The maximum random factor, must not be lesser than 1. Default value: 1.1.

public static DataOptions UseRetryPolicy(this DataOptions options, IRetryPolicy retryPolicy)

Uses retry policy.

public static DataOptions UseSapHana(this DataOptions options, Func<SapHanaOptions, SapHanaOptions> optionSetter = null)

Configure connection to use SAP HANA default provider.

public static DataOptions UseSapHana(this DataOptions options, string connectionString, Func<SapHanaOptions, SapHanaOptions> optionSetter = null)

Configure connection to use SAP HANA default provider and connection string.

public static DataOptions UseSapHanaNative(this DataOptions options, Func<SapHanaOptions, SapHanaOptions> optionSetter = null)

Configure connection to use native SAP HANA provider.

public static DataOptions UseSapHanaNative(this DataOptions options, string connectionString, Func<SapHanaOptions, SapHanaOptions> optionSetter = null)

Configure connection to use native SAP HANA provider and connection string.

public static DataOptions UseSapHanaODBC(this DataOptions options, Func<SapHanaOptions, SapHanaOptions> optionSetter = null)

Configure connection to use SAP HANA ODBC provider.

public static DataOptions UseSapHanaODBC(this DataOptions options, string connectionString, Func<SapHanaOptions, SapHanaOptions> optionSetter = null)

Configure connection to use SAP HANA ODBC provider and connection string.

public static DataOptions UseSqlCe(this DataOptions options, Func<SqlCeOptions, SqlCeOptions> optionSetter = null)

Configure connection to use SQL CE provider.

public static DataOptions UseSqlCe(this DataOptions options, string connectionString, Func<SqlCeOptions, SqlCeOptions> optionSetter = null)

Configure connection to use SQL CE provider and connection string.

public static DataOptions UseSQLite(this DataOptions options, Func<SQLiteOptions, SQLiteOptions> optionSetter = null)

Configure connection to use SQLite default provider.

public static DataOptions UseSQLite(this DataOptions options, string connectionString, Func<SQLiteOptions, SQLiteOptions> optionSetter = null)

Configure connection to use SQLite default provider and connection string.

public static DataOptions UseSQLiteMicrosoft(this DataOptions options, Func<SQLiteOptions, SQLiteOptions> optionSetter = null)

Configure connection to use Microsoft.Data.Sqlite SQLite provider.

public static DataOptions UseSQLiteMicrosoft(this DataOptions options, string connectionString, Func<SQLiteOptions, SQLiteOptions> optionSetter = null)

Configure connection to use Microsoft.Data.Sqlite SQLite provider and connection string.

public static DataOptions UseSQLiteOfficial(this DataOptions options, Func<SQLiteOptions, SQLiteOptions> optionSetter = null)

Configure connection to use System.Data.Sqlite SQLite provider.

public static DataOptions UseSQLiteOfficial(this DataOptions options, string connectionString, Func<SQLiteOptions, SQLiteOptions> optionSetter = null)

Configure connection to use System.Data.Sqlite SQLite provider and connection string.

public static DataOptions UseSqlServer(this DataOptions options, SqlServerVersion dialect = 0, SqlServerProvider provider = 0, Func<SqlServerOptions, SqlServerOptions> optionSetter = null)

Configure connection to use specific SQL Server provider, dialect and provider-specific options.

public static DataOptions UseSqlServer(this DataOptions options, string connectionString, SqlServerVersion dialect = 0, SqlServerProvider provider = 0, Func<SqlServerOptions, SqlServerOptions> optionSetter = null)

Configure connection to use specific SQL Server provider, dialect, connection string and provider-specific options.

public static DataOptions UseTraceLevel(this DataOptions options, TraceLevel traceLevel)

Configure the database to use specified trace level.

public static DataOptions UseTraceMapperExpression(this DataOptions options, bool traceMapperExpression)

Enables logging of generated mapping expression to data connection tracing infrastructure. See TraceSwitch for more details. Default value: false.

public static DataOptions UseTraceWith(this DataOptions options, Action<string, string, TraceLevel> write)

Configure the database to use the specified a string trace callback.

public static DataOptions UseTracing(this DataOptions options, Action<TraceInfo> onTrace)

Configure the database to use the specified callback for logging or tracing.

public static DataOptions UseTracing(this DataOptions options, TraceLevel traceLevel, Action<TraceInfo> onTrace)

Configure the database to use the specified trace level and callback for logging or tracing.

public static DataOptions UseTransaction(this DataOptions options, IDataProvider dataProvider, DbTransaction transaction)

Defines data provider and transaction to use with DataOptions.

public static ConnectionOptions WithAfterConnectionOpened(this ConnectionOptions options, Action<DbConnection> afterConnectionOpened, Func<DbConnection, CancellationToken, Task> afterConnectionOpenedAsync = null)

Sets custom actions, executed after connection opened.

public static ConnectionOptions WithBeforeConnectionOpened(this ConnectionOptions options, Action<DbConnection> afterConnectionOpening, Func<DbConnection, CancellationToken, Task> afterConnectionOpeningAsync = null)

Sets custom actions, executed before connection opened.

public static BulkCopyOptions WithBulkCopyTimeout(this BulkCopyOptions options, int? bulkCopyTimeout)

Number of seconds for the operation to complete before it times out.

public static BulkCopyOptions WithBulkCopyType(this BulkCopyOptions options, BulkCopyType bulkCopyType)

Bulk copy mode.

public static LinqOptions WithCacheSlidingExpiration(this LinqOptions options, TimeSpan? cacheSlidingExpiration)

Specifies timeout when query will be evicted from cache since last execution of query. Default value is 1 hour.

public static BulkCopyOptions WithCheckConstraints(this BulkCopyOptions options, bool? checkConstraints)

Checks constraints while data is being inserted.

public static RetryPolicyOptions WithCoefficient(this RetryPolicyOptions options, TimeSpan coefficient)

The coefficient for the exponential function used to compute the delay between retries, must be nonnegative. Default value: 1 second.

public static LinqOptions WithCompareNullsAsValues(this LinqOptions options, bool compareNullsAsValues)

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 ConnectionOptions WithConfigurationString(this ConnectionOptions options, string configurationString)

Sets ConfigurationString option.

public static ConnectionOptions WithConnectionFactory(this ConnectionOptions options, Func<DataOptions, DbConnection> connectionFactory)

Sets ConnectionFactory option.

public static ConnectionOptions WithConnectionString(this ConnectionOptions options, string connectionString)

Sets ConnectionString option.

public static BulkCopyOptions WithDatabaseName(this BulkCopyOptions options, string databaseName)

Gets or sets explicit name of target database instead of one, configured for copied entity in mapping schema. See DatabaseName<T> method for support information per provider.

public static ConnectionOptions WithDataProvider(this ConnectionOptions options, IDataProvider dataProvider)

Sets DataProvider option.

Sets DataProviderFactory option.

public static ConnectionOptions WithDbConnection(this ConnectionOptions options, DbConnection connection)

Sets DbConnection option.

public static ConnectionOptions WithDbTransaction(this ConnectionOptions options, DbTransaction transaction)

Sets DbTransaction option.

public static LinqOptions WithDisableQueryCache(this LinqOptions options, bool disableQueryCache)

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 ConnectionOptions WithDisposeConnection(this ConnectionOptions options, bool disposeConnection)

Sets DisposeConnection option.

public static LinqOptions WithDoNotClearOrderBys(this LinqOptions options, bool doNotClearOrderBys)

Controls behavior, when LINQ query chain contains multiple OrderBy<T, U> or OrderByDescending<T, U> 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 WithEnableContextSchemaEdit(this LinqOptions options, bool enableContextSchemaEdit)

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 RetryPolicyOptions WithExponentialBase(this RetryPolicyOptions options, double exponentialBase)

The base for the exponential function used to compute the delay between retries, must be positive. Default value: 2.

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 BulkCopyOptions WithFireTriggers(this BulkCopyOptions options, bool? fireTriggers)

When specified, causes the server to fire the insert triggers for the rows being inserted into the database.

public static LinqOptions WithGenerateExpressionTest(this LinqOptions options, bool generateExpressionTest)

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 WithGuardGrouping(this LinqOptions options, bool guardGrouping)

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 option. Default value: true.

public static LinqOptions WithIgnoreEmptyUpdate(LinqOptions options, bool ignoreEmptyUpdate)

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 WithKeepDistinctOrdered(this LinqOptions options, bool keepDistinctOrdered)

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 BulkCopyOptions WithKeepIdentity(this BulkCopyOptions options, bool? keepIdentity)

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 WithKeepNulls(this BulkCopyOptions options, bool? keepNulls)

Preserves null values in the destination table regardless of the settings for default values.

public static ConnectionOptions WithMappingSchema(this ConnectionOptions options, MappingSchema mappingSchema)

Sets MappingSchema option.

public static BulkCopyOptions WithMaxBatchSize(this BulkCopyOptions options, int? maxBatchSize)

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 WithMaxDegreeOfParallelism(this BulkCopyOptions options, int? maxDegreeOfParallelism)

Implemented only by ClickHouse.Client provider. Defines number of connections, used for parallel insert in ProviderSpecific mode.

public static RetryPolicyOptions WithMaxDelay(this RetryPolicyOptions options, TimeSpan maxDelay)

The maximum time delay between retries, must be nonnegative. Default value: 30 seconds.

public static BulkCopyOptions WithMaxParametersForBatch(this BulkCopyOptions options, int? maxParametersForBatch)

If set, will override the Maximum parameters per batch statement from MaxParameters.

public static RetryPolicyOptions WithMaxRetryCount(this RetryPolicyOptions options, int maxRetryCount)

The number of retry attempts. Default value: 5.

public static BulkCopyOptions WithNotifyAfter(this BulkCopyOptions options, int notifyAfter)

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).

Sets OnEntityDescriptorCreated option.

public static QueryTraceOptions WithOnTrace(this QueryTraceOptions options, Action<TraceInfo> onTrace)

Configure the database to use the specified callback for logging or tracing.

public static LinqOptions WithOptimizeJoins(this LinqOptions options, bool optimizeJoins)

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 WithParameterizeTakeSkip(this LinqOptions options, bool parameterizeTakeSkip)

Enables Take/Skip parameterization. Default value: true.

public static LinqOptions WithPreferApply(this LinqOptions options, bool preferApply)

Used to generate CROSS APPLY or OUTER APPLY if possible. Default value: true.

public static LinqOptions WithPreferExistsForScalar(this LinqOptions options, bool preferExistsForScalar)

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 WithPreloadGroups(this LinqOptions options, bool preloadGroups)

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<T, U>. Default value: false.

public static ConnectionOptions WithProviderName(this ConnectionOptions options, string providerName)

Sets ProviderName option.

public static RetryPolicyOptions WithRandomFactor(this RetryPolicyOptions options, double randomFactor)

The maximum random factor, must not be lesser than 1. Default value: 1.1.

public static RetryPolicyOptions WithRetryPolicy(this RetryPolicyOptions options, IRetryPolicy retryPolicy)

Uses retry policy

public static BulkCopyOptions WithRowsCopiedCallback(this BulkCopyOptions options, Action<BulkCopyRowsCopied> rowsCopiedCallback)

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 WithSchemaName(this BulkCopyOptions options, string schemaName)

Gets or sets explicit name of target schema/owner instead of one, configured for copied entity in mapping schema. See SchemaName<T> method for support information per provider.

public static BulkCopyOptions WithServerName(this BulkCopyOptions options, string serverName)

Gets or sets explicit name of target server instead of one, configured for copied entity in mapping schema. See ServerName<T> method for support information per provider. Also note that it is not supported by provider-specific insert method.

public static BulkCopyOptions WithTableLock(this BulkCopyOptions options, bool? tableLock)

Obtains a bulk update lock for the duration of the bulk copy operation.

public static BulkCopyOptions WithTableName(this BulkCopyOptions options, string tableName)

Gets or sets explicit name of target table instead of one, configured for copied entity in mapping schema.

public static BulkCopyOptions WithTableOptions(this BulkCopyOptions options, TableOptions tableOptions)

Gets or sets TableOptions flags overrides instead of configured for copied entity in mapping schema. See IsTemporary<T> method for support information per provider.

public static QueryTraceOptions WithTraceLevel(this QueryTraceOptions options, TraceLevel traceLevel)

Configure the database to use specified trace level.

public static LinqOptions WithTraceMapperExpression(this LinqOptions options, bool traceMapperExpression)

Enables logging of generated mapping expression to data connection tracing infrastructure. See TraceSwitch for more details. Default value: false.

public static BulkCopyOptions WithUseInternalTransaction(this BulkCopyOptions options, bool? useInternalTransaction)

When specified, each batch of the bulk-copy operation will occur within a transaction.

public static BulkCopyOptions WithUseParameters(this BulkCopyOptions options, bool useParameters)

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 WithWithoutSession(this BulkCopyOptions options, bool withoutSession)

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 QueryTraceOptions WithWriteTrace(this QueryTraceOptions options, Action<string, string, TraceLevel> write)

Configure the database to use the specified a string trace callback.