Class LegacyMergeExtensions
Contains extension methods for DataConnection class.
[Obsolete("Legacy Merge API obsoleted and not recommended for use. See migration guide https://linq2db.github.io/articles/sql/merge/Merge-API-Migration.html or direct translation of old API to new one in code of this method https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Data/LegacyMergeExtensions.cs.")]
public static class LegacyMergeExtensions
- Inheritance
-
LegacyMergeExtensions
- Inherited Members
Methods
MergeAsync<T>(DataConnection, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source (optional).
If delete operation enabled by
deleteparameter - method could be used only with SQL Server.
public static Task<int> MergeAsync<T>(this DataConnection dataConnection, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnectionDataConnectionData connection instance.
deleteboolIf true, merge command will include delete by source operation without condition.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
cancellationTokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget table mapping class.
MergeAsync<T>(DataConnection, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert.
public static Task<int> MergeAsync<T>(this DataConnection dataConnection, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnectionDataConnectionData connection instance.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
cancellationTokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget table mapping class.
MergeAsync<T>(DataConnection, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
public static Task<int> MergeAsync<T>(this DataConnection dataConnection, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnectionDataConnectionData connection instance.
predicateExpression<Func<T, bool>>Filter, applied to delete operation. Optional.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
cancellationTokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget table mapping class.
MergeAsync<T>(DataConnection, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
public static Task<int> MergeAsync<T>(this DataConnection dataConnection, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
dataConnectionDataConnectionData connection instance.
sourceIQueryable<T>Source data to merge into target table. All source data will be loaded from server for command generation.
predicateExpression<Func<T, bool>>Filter, applied both to source and delete operation. Required.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
cancellationTokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget table mapping class.
MergeAsync<T>(ITable<T>, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source (optional).
If delete operation enabled by
deleteparameter - method could be used only with SQL Server.
public static Task<int> MergeAsync<T>(this ITable<T> table, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
tableITable<T>Target table.
deleteboolIf true, merge command will include delete by source operation without condition.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
cancellationTokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget table mapping class.
MergeAsync<T>(ITable<T>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert.
public static Task<int> MergeAsync<T>(this ITable<T> table, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
tableITable<T>Target table.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
cancellationTokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget table mapping class.
MergeAsync<T>(ITable<T>, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
public static Task<int> MergeAsync<T>(this ITable<T> table, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
tableITable<T>Target table.
predicateExpression<Func<T, bool>>Filter, applied to delete operation. Optional.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
cancellationTokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget table mapping class.
MergeAsync<T>(ITable<T>, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions, CancellationToken)
Executes following merge operations asynchronously in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
public static Task<int> MergeAsync<T>(this ITable<T> table, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet, CancellationToken cancellationToken = default) where T : class
Parameters
tableITable<T>Target table.
sourceIQueryable<T>Source data to merge into target table. All source data will be loaded from server for command generation.
predicateExpression<Func<T, bool>>Filter, applied both to source and delete operation. Required.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
cancellationTokenCancellationTokenOptional asynchronous operation cancellation token.
Returns
Type Parameters
TTarget table mapping class.
Merge<T>(DataConnection, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source (optional).
If delete operation enabled by
deleteparameter - method could be used only for with Server.
public static int Merge<T>(this DataConnection dataConnection, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
dataConnectionDataConnectionData connection instance.
deleteboolIf true, merge command will include delete by source operation without condition.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
TTarget table mapping class.
Merge<T>(DataConnection, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert.
public static int Merge<T>(this DataConnection dataConnection, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
dataConnectionDataConnectionData connection instance.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
TTarget table mapping class.
Merge<T>(DataConnection, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
public static int Merge<T>(this DataConnection dataConnection, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
dataConnectionDataConnectionData connection instance.
predicateExpression<Func<T, bool>>Filter, applied to delete operation. Optional.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
TTarget table mapping class.
Merge<T>(DataConnection, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
public static int Merge<T>(this DataConnection dataConnection, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
dataConnectionDataConnectionData connection instance.
sourceIQueryable<T>Source data to merge into target table. All source data will be loaded from server for command generation.
predicateExpression<Func<T, bool>>Filter, applied both to source and delete operation. Required.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
TTarget table mapping class.
Merge<T>(ITable<T>, bool, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source (optional).
If delete operation enabled by
deleteparameter - method could be used only with SQL Server.
public static int Merge<T>(this ITable<T> table, bool delete, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
tableITable<T>Target table.
deleteboolIf true, merge command will include delete by source operation without condition.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
TTarget table mapping class.
Merge<T>(ITable<T>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert.
public static int Merge<T>(this ITable<T> table, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
tableITable<T>Target table.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
TTarget table mapping class.
Merge<T>(ITable<T>, Expression<Func<T, bool>>, IEnumerable<T>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
public static int Merge<T>(this ITable<T> table, Expression<Func<T, bool>> predicate, IEnumerable<T> source, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
tableITable<T>Target table.
predicateExpression<Func<T, bool>>Filter, applied to delete operation. Optional.
sourceIEnumerable<T>Source data to merge into target table.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
TTarget table mapping class.
Merge<T>(ITable<T>, IQueryable<T>, Expression<Func<T, bool>>, string?, string?, string?, string?, TableOptions)
Executes following merge operations in specified order:
- Update
- Insert
- Delete By Source. Method could be used only with SQL Server.
public static int Merge<T>(this ITable<T> table, IQueryable<T> source, Expression<Func<T, bool>> predicate, string? tableName = null, string? databaseName = null, string? schemaName = null, string? serverName = null, TableOptions tableOptions = TableOptions.NotSet) where T : class
Parameters
tableITable<T>Target table.
sourceIQueryable<T>Source data to merge into target table. All source data will be loaded from server for command generation.
predicateExpression<Func<T, bool>>Filter, applied both to source and delete operation. Required.
tableNamestringOptional target table name.
databaseNamestringOptional target table's database name.
schemaNamestringOptional target table's schema name.
serverNamestringOptional name of linked server. If not specified, value from mapping will be used.
tableOptionsTableOptionsTable options. See TableOptions enum for support information per provider.
Returns
- int
Returns number of affected target records.
Type Parameters
TTarget table mapping class.