コード例 #1
0
        public TEntity Update <TEntity>(TEntity entity, int?version = null) where TEntity : class
        {
            var sql = dapperSqlGenerator?.Update(entity);

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

            return(entity);
        }
コード例 #2
0
    public async Task <TEntity> Update(TEntity entity, int?expectedVersion, CancellationToken cancellationToken = default)
    {
        if (expectedVersion.HasValue)
        {
            throw new NotImplementedException();
        }

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

        var sql = dapperSqlGenerator?.Update(entity);

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

        aggregateEventsPublisher.TryEnqueueEventsFrom(entity, out _);

        return(entity);
    }
コード例 #3
0
        public TEntity Update(TEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var sql = dapperSqlGenerator?.Update(entity);

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

            return(entity);
        }