/// <summary> /// Inserts into this database table from database recordset. /// </summary> /// <typeparam name="TSource">Entity type of database recordset.</typeparam> /// <param name="source">The source database recordset.</param> /// <param name="columnMapper">Provides column mappings between source database recordset and this table.</param> /// <param name="ct">The async cancellation token.</param> /// <returns>Number of records inserted into this database table.</returns> public Task <int> InsertAsync <TSource>(DbSet <TSource> source, Action <ColumnMapper, TSource, T> columnMapper, CancellationToken ct = default(CancellationToken)) where TSource : class, IEntity, new() { Verify(source, nameof(source)); var columnMappings = Verify(columnMapper, nameof(columnMapper), source._); return(DbTableInsert <T> .ExecuteAsync(this, source, columnMappings, ct)); }
/// <summary> /// Inserts specified DataRow in DataSet into this table. /// </summary> /// <typeparam name="TSource">Entity type of source DataSet.</typeparam> /// <param name="source">The source DataSet.</param> /// <param name="ordinal">The ordianl to specify the source DataRow.</param> /// <param name="columnMapper">Provides column mappings between source DataSet and this table.</param> /// <param name="updateIdentity">Specifies whether source DataSet identity column should be updated with newly generated value.</param> /// <param name="ct">The async cancellation token.</param> /// <returns>Number of records inserted into this database table.</returns> public Task <int> InsertAsync <TSource>(DataSet <TSource> source, int ordinal, Action <ColumnMapper, TSource, T> columnMapper, bool updateIdentity, CancellationToken ct = default(CancellationToken)) where TSource : class, IEntity, new() { Verify(source, nameof(source), ordinal, nameof(ordinal)); var columnMappings = Verify(columnMapper, nameof(columnMapper), source._); VerifyUpdateIdentity(updateIdentity, nameof(updateIdentity)); return(DbTableInsert <T> .ExecuteAsync(this, source, ordinal, columnMappings, updateIdentity, ct)); }
/// <summary> /// Inserts into this table from DataSet. /// </summary> /// <typeparam name="TSource">Entity type of source DataSet.</typeparam> /// <param name="source">The source DataSet.</param> /// <param name="columnMapper">Provides column mappings between source DataSet and this table.</param> /// <param name="updateIdentity">Specifies whether source DataSet identity column should be updated with newly generated values.</param> /// <param name="ct">The async cancellation token.</param> /// <returns>Number of records inserted into this database table.</returns> public Task <int> InsertAsync <TSource>(DataSet <TSource> source, Action <ColumnMapper, TSource, T> columnMapper, bool updateIdentity, CancellationToken ct = default(CancellationToken)) where TSource : class, IEntity, new() { Verify(source, nameof(source)); if (source.Count == 1) { return(InsertAsync(source, 0, columnMapper, updateIdentity, ct)); } Verify(columnMapper, nameof(columnMapper)); VerifyUpdateIdentity(updateIdentity, nameof(updateIdentity)); return(DbTableInsert <T> .ExecuteAsync(this, source, columnMapper, updateIdentity, ct)); }
/// <summary> /// Inserts values into this database table. /// </summary> /// <param name="columnMapper">Provides Column mappings between value and column in this table.</param> /// <param name="outputIdentity">Delegate to receive newly generated identity value.</param> /// <param name="ct">The async cancellation token.</param> /// <returns>Number of records inserted into this database table.</returns> public Task <int> InsertAsync(Action <ColumnMapper, T> columnMapper, Action <long?> outputIdentity, CancellationToken ct = default(CancellationToken)) { var columnMappings = Verify(columnMapper, nameof(columnMapper)); return(DbTableInsert <T> .ExecuteAsync(this, columnMappings, outputIdentity, ct)); }
/// <summary> /// Inserts default values into this database table. /// </summary> /// <param name="outputIdentity">Delegate to receive newly generated identity value.</param> /// <param name="ct">The async cancellation token.</param> /// <returns>Number of records inserted into this database table.</returns> public Task <int> InsertAsync(Action <long?> outputIdentity, CancellationToken ct = default(CancellationToken)) { return(DbTableInsert <T> .ExecuteAsync(this, Array.Empty <ColumnMapping>(), outputIdentity, ct)); }
/// <summary> /// Inserts default values into this database table. /// </summary> /// <param name="ct">The async cancellation token.</param> /// <returns>Number of records inserted into this database table.</returns> public Task <int> InsertAsync(CancellationToken ct = default(CancellationToken)) { return(DbTableInsert <T> .ExecuteAsync(this, Array.Empty <ColumnMapping>(), null, ct)); }