Esempio n. 1
0
        /// <summary>
        /// Deletes from matching row in DataSet.
        /// </summary>
        /// <typeparam name="TSource">Entity type of the source DataSet.</typeparam>
        /// <param name="source">The source matching DataSet.</param>
        /// <param name="rowIndex">The row index in the DataSet.</param>
        /// <param name="keyMapper">Provides key mapping between source DataSet and this table.</param>
        /// <param name="ct">The async cancellation token.</param>
        /// <returns>Number of records deleted.</returns>
        public Task <int> DeleteAsync <TSource>(DataSet <TSource> source, int rowIndex, Func <TSource, T, KeyMapping> keyMapper, CancellationToken ct = default(CancellationToken))
            where TSource : class, IEntity, new()
        {
            VerifyDeletable();
            Verify(source, nameof(source), rowIndex, nameof(rowIndex));
            var columnMappings = Verify(keyMapper, nameof(keyMapper), source._).GetColumnMappings();

            return(DbTableDelete <T> .ExecuteAsync(this, source, rowIndex, columnMappings, ct));
        }
Esempio n. 2
0
        /// <summary>
        /// Deletes records in this database table from matching database recordset.
        /// </summary>
        /// <typeparam name="TSource">Entity type of the source database recordset.</typeparam>
        /// <param name="source">The matching database recordset.</param>
        /// <param name="keyMapper">Provides key mapping between source database recordset and this table.</param>
        /// <param name="ct">The async cancellation token.</param>
        /// <returns>Number of records deleted.</returns>
        public Task <int> DeleteAsync <TSource>(DbSet <TSource> source, Func <TSource, T, KeyMapping> keyMapper, CancellationToken ct = default(CancellationToken))
            where TSource : Model, new()
        {
            VerifyDeletable();
            Verify(source, nameof(source));
            var columnMappings = Verify(keyMapper, nameof(keyMapper), source._).GetColumnMappings();

            return(DbTableDelete <T> .ExecuteAsync(this, source, columnMappings, ct));
        }
Esempio n. 3
0
        /// <summary>
        /// Deletes records in this database table from matching DataSet.
        /// </summary>
        /// <typeparam name="TSource">Entity type of the source DataSet.</typeparam>
        /// <param name="source">The source matching DataSet.</param>
        /// <param name="keyMapper">Provides key mapping between source DataSet and this table.</param>
        /// <param name="ct">The async cancellation token.</param>
        /// <returns>Number of records deleted.</returns>
        public Task <int> DeleteAsync <TSource>(DataSet <TSource> source, Func <TSource, T, KeyMapping> keyMapper, CancellationToken ct = default(CancellationToken))
            where TSource : class, IEntity, new()
        {
            Verify(source, nameof(source));
            if (source.Count == 1)
            {
                return(DeleteAsync(source, 0, keyMapper, ct));
            }

            VerifyDeletable();
            var targetKey = Verify(keyMapper, nameof(keyMapper), source._).TargetKey;

            return(DbTableDelete <T> .ExecuteAsync(this, source, targetKey, ct));
        }
Esempio n. 4
0
 /// <summary>
 /// Deletes records in this database table by condition.
 /// </summary>
 /// <param name="where">The condition.</param>
 /// <param name="ct">The async cancellation token.</param>
 /// <returns>Number of records deleted.</returns>
 public Task <int> DeleteAsync(Func <T, _Boolean> where, CancellationToken ct = default(CancellationToken))
 {
     VerifyDeletable();
     return(DbTableDelete <T> .ExecuteAsync(this, where, ct));
 }