Skip to content

Commit

Permalink
Merge pull request #490 from sqlkata/feature/increment-update
Browse files Browse the repository at this point in the history
add increment execution
  • Loading branch information
ahmad-moussawi authored Jun 10, 2021
2 parents f77efa0 + a79c21f commit b762ed9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions SqlKata.Execution/Query.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,26 @@ public static async Task<int> UpdateAsync(this Query query, object data, IDbTran
return await CreateQueryFactory(query).ExecuteAsync(query.AsUpdate(data), transaction, timeout, cancellationToken);
}

public static int Increment(this Query query, string column, int value = 1, IDbTransaction transaction = null, int? timeout = null)
{
return CreateQueryFactory(query).Execute(query.AsIncrement(column, value), transaction, timeout);
}

public static async Task<int> IncrementAsync(this Query query, string column, int value = 1, IDbTransaction transaction = null, int? timeout = null, CancellationToken cancellationToken = default)
{
return await CreateQueryFactory(query).ExecuteAsync(query.AsIncrement(column, value), transaction, timeout, cancellationToken);
}

public static int Decrement(this Query query, string column, int value = 1, IDbTransaction transaction = null, int? timeout = null)
{
return CreateQueryFactory(query).Execute(query.AsDecrement(column, value), transaction, timeout);
}

public static async Task<int> DecrementAsync(this Query query, string column, int value = 1, IDbTransaction transaction = null, int? timeout = null, CancellationToken cancellationToken = default)
{
return await CreateQueryFactory(query).ExecuteAsync(query.AsDecrement(column, value), transaction, timeout, cancellationToken);
}

public static int Delete(this Query query, IDbTransaction transaction = null, int? timeout = null)
{
return CreateQueryFactory(query).Execute(query.AsDelete(), transaction, timeout);
Expand Down

0 comments on commit b762ed9

Please sign in to comment.