Skip to content

Commit

Permalink
add increment execution
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-moussawi committed Jun 10, 2021
1 parent 550122d commit a79c21f
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 a79c21f

Please sign in to comment.