Exemplo n.º 1
0
    public async Task <TEntity> Delete(TEntity entity, int?expectedVersion, CancellationToken cancellationToken = default)
    {
        if (expectedVersion.HasValue)
        {
            throw new NotImplementedException();
        }

        if (entity == null)
        {
            throw new ArgumentNullException(nameof(entity));
        }

        var sql = dapperSqlGenerator?.Delete(entity);

        if (!sql.IsNullOrEmpty())
        {
            await dbConnection.ExecuteAsync(sql, entity);
        }
        else
        {
            await dbConnection.DeleteAsync(entity);
        }

        aggregateEventsPublisher.TryEnqueueEventsFrom(entity, out _);

        return(entity);
    }
Exemplo n.º 2
0
        public TEntity Remove <TEntity>(TEntity entity, int?version = null) where TEntity : class
        {
            var sql = dapperSqlGenerator?.Delete(entity);

            if (!sql.IsNullOrEmpty())
            {
                dbConnection.Execute(sql, entity);
            }
            else
            {
                dbConnection.Delete(entity);
            }
            return(entity);
        }
Exemplo n.º 3
0
        public TEntity Delete(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var sql = dapperSqlGenerator?.Delete(entity);

            if (!sql.IsNullOrEmpty())
            {
                dbConnection.Execute(sql, entity);
            }
            else
            {
                dbConnection.Delete(entity);
            }
            return(entity);
        }