Skip to content

Commit

Permalink
Completely expose the 'fields' argument to 'InsertAll' operation. #523
Browse files Browse the repository at this point in the history
  • Loading branch information
mikependon committed Aug 23, 2020
1 parent 65fe812 commit 4033b48
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions RepoDb.Core/RepoDb/Operations/BaseRepository/InsertAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ public abstract partial class BaseRepository<TEntity, TDbConnection> : IDisposab
/// </summary>
/// <param name="entities">The data entity objects to be inserted.</param>
/// <param name="batchSize">The batch size of the insertion.</param>
/// <param name="fields">The mapping list of <see cref="Field"/> objects to be used.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <returns>The number of inserted rows in the table.</returns>
public int InsertAll(IEnumerable<TEntity> entities,
int batchSize = Constant.DefaultBatchOperationSize,
IEnumerable<Field> fields = null,
string hints = null,
IDbTransaction transaction = null)
{
return DbRepository.InsertAll<TEntity>(entities: entities,
batchSize: batchSize,
fields: fields,
hints: hints,
transaction: transaction);
}
Expand All @@ -40,16 +43,19 @@ public int InsertAll(IEnumerable<TEntity> entities,
/// </summary>
/// <param name="entities">The data entity objects to be inserted.</param>
/// <param name="batchSize">The batch size of the insertion.</param>
/// <param name="fields">The mapping list of <see cref="Field"/> objects to be used.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <returns>The number of inserted rows in the table.</returns>
public Task<int> InsertAllAsync(IEnumerable<TEntity> entities,
int batchSize = Constant.DefaultBatchOperationSize,
IEnumerable<Field> fields = null,
string hints = null,
IDbTransaction transaction = null)
{
return DbRepository.InsertAllAsync<TEntity>(entities: entities,
batchSize: batchSize,
fields: fields,
hints: hints,
transaction: transaction);
}
Expand Down
12 changes: 9 additions & 3 deletions RepoDb.Core/RepoDb/Operations/DbConnection/InsertAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static int InsertAll<TEntity>(this IDbConnection connection,
/// <param name="connection">The connection object to be used.</param>
/// <param name="entities">The list of data entity objects to be inserted.</param>
/// <param name="batchSize">The batch size of the insertion.</param>
/// <param name="fields">The mapping list of <see cref="Field"/> objects to be used.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="commandTimeout">The command timeout in seconds to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
Expand All @@ -74,6 +75,7 @@ public static int InsertAll<TEntity>(this IDbConnection connection,
public static int InsertAll<TEntity>(this IDbConnection connection,
IEnumerable<TEntity> entities,
int batchSize = Constant.DefaultBatchOperationSize,
IEnumerable<Field> fields = null,
string hints = null,
int? commandTimeout = null,
IDbTransaction transaction = null,
Expand All @@ -85,6 +87,7 @@ public static int InsertAll<TEntity>(this IDbConnection connection,
tableName: ClassMappedNameCache.Get<TEntity>(),
entities: entities,
batchSize: batchSize,
fields: fields,
hints: hints,
commandTimeout: commandTimeout,
transaction: transaction,
Expand Down Expand Up @@ -166,7 +169,7 @@ public static Task<int> InsertAllAsync<TEntity>(this IDbConnection connection,
tableName: tableName,
entities: entities,
batchSize: batchSize,
fields: GetQualifiedFields<TEntity>(fields, entities?.FirstOrDefault()),
fields: fields,
hints: hints,
commandTimeout: commandTimeout,
transaction: transaction,
Expand All @@ -181,6 +184,7 @@ public static Task<int> InsertAllAsync<TEntity>(this IDbConnection connection,
/// <param name="connection">The connection object to be used.</param>
/// <param name="entities">The list of data entity objects to be inserted.</param>
/// <param name="batchSize">The batch size of the insertion.</param>
/// <param name="fields">The mapping list of <see cref="Field"/> objects to be used.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="commandTimeout">The command timeout in seconds to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
Expand All @@ -190,6 +194,7 @@ public static Task<int> InsertAllAsync<TEntity>(this IDbConnection connection,
public static Task<int> InsertAllAsync<TEntity>(this IDbConnection connection,
IEnumerable<TEntity> entities,
int batchSize = Constant.DefaultBatchOperationSize,
IEnumerable<Field> fields = null,
string hints = null,
int? commandTimeout = null,
IDbTransaction transaction = null,
Expand All @@ -201,6 +206,7 @@ public static Task<int> InsertAllAsync<TEntity>(this IDbConnection connection,
tableName: ClassMappedNameCache.Get<TEntity>(),
entities: entities,
batchSize: batchSize,
fields: fields,
hints: hints,
commandTimeout: commandTimeout,
transaction: transaction,
Expand Down Expand Up @@ -276,7 +282,7 @@ public static int InsertAll(this IDbConnection connection,
ITrace trace = null,
IStatementBuilder statementBuilder = null)
{
return InsertAllInternal(connection: connection,
return InsertAllInternal<object>(connection: connection,
tableName: tableName,
entities: entities,
batchSize: batchSize,
Expand Down Expand Up @@ -317,7 +323,7 @@ public static Task<int> InsertAllAsync(this IDbConnection connection,
ITrace trace = null,
IStatementBuilder statementBuilder = null)
{
return InsertAllAsyncInternal(connection: connection,
return InsertAllAsyncInternal<object>(connection: connection,
tableName: tableName,
entities: entities,
batchSize: batchSize,
Expand Down
6 changes: 6 additions & 0 deletions RepoDb.Core/RepoDb/Operations/DbRepository/InsertAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ public int InsertAll<TEntity>(string tableName,
/// <typeparam name="TEntity">The type of the data entity.</typeparam>
/// <param name="entities">The data entity objects to be inserted.</param>
/// <param name="batchSize">The batch size of the insertion.</param>
/// <param name="fields">The mapping list of <see cref="Field"/> objects to be used.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <returns>The number of inserted rows in the table.</returns>
public int InsertAll<TEntity>(IEnumerable<TEntity> entities,
int batchSize = Constant.DefaultBatchOperationSize,
IEnumerable<Field> fields = null,
string hints = null,
IDbTransaction transaction = null)
where TEntity : class
Expand All @@ -84,6 +86,7 @@ public int InsertAll<TEntity>(IEnumerable<TEntity> entities,
// Call the method
return connection.InsertAll<TEntity>(entities: entities,
batchSize: batchSize,
fields: fields,
hints: hints,
commandTimeout: CommandTimeout,
transaction: transaction,
Expand Down Expand Up @@ -159,11 +162,13 @@ public async Task<int> InsertAllAsync<TEntity>(string tableName,
/// <typeparam name="TEntity">The type of the data entity.</typeparam>
/// <param name="entities">The data entity objects to be inserted.</param>
/// <param name="batchSize">The batch size of the insertion.</param>
/// <param name="fields">The mapping list of <see cref="Field"/> objects to be used.</param>
/// <param name="hints">The table hints to be used.</param>
/// <param name="transaction">The transaction to be used.</param>
/// <returns>The number of inserted rows in the table.</returns>
public async Task<int> InsertAllAsync<TEntity>(IEnumerable<TEntity> entities,
int batchSize = Constant.DefaultBatchOperationSize,
IEnumerable<Field> fields = null,
string hints = null,
IDbTransaction transaction = null)
where TEntity : class
Expand All @@ -176,6 +181,7 @@ public async Task<int> InsertAllAsync<TEntity>(IEnumerable<TEntity> entities,
// Call the method
return await connection.InsertAllAsync<TEntity>(entities: entities,
batchSize: batchSize,
fields: fields,
hints: hints,
commandTimeout: CommandTimeout,
transaction: transaction,
Expand Down

0 comments on commit 4033b48

Please sign in to comment.