From a79c21fb95a3c4971a0d8f232b8657d4b9b2a458 Mon Sep 17 00:00:00 2001 From: Ahmad Moussawi Date: Thu, 10 Jun 2021 22:15:23 +0300 Subject: [PATCH] add increment execution --- SqlKata.Execution/Query.Extensions.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/SqlKata.Execution/Query.Extensions.cs b/SqlKata.Execution/Query.Extensions.cs index 5f3eeefd..a3aadf35 100644 --- a/SqlKata.Execution/Query.Extensions.cs +++ b/SqlKata.Execution/Query.Extensions.cs @@ -245,6 +245,26 @@ public static async Task 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 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 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);