Skip to content

Commit f4e074a

Browse files
merge execution files and add transactions support for all methods
1 parent f40fc8d commit f4e074a

File tree

10 files changed

+1024
-1064
lines changed

10 files changed

+1024
-1064
lines changed

QueryBuilder.Tests/AggregateTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Count()
2222
[Fact]
2323
public void CountMultipleColumns()
2424
{
25-
var query = new Query("A").AsCount("ColumnA", "ColumnB");
25+
var query = new Query("A").AsCount(new[] { "ColumnA", "ColumnB" });
2626

2727
var c = Compile(query);
2828

@@ -42,7 +42,7 @@ public void DistinctCount()
4242
[Fact]
4343
public void DistinctCountMultipleColumns()
4444
{
45-
var query = new Query("A").Distinct().AsCount("ColumnA", "ColumnB");
45+
var query = new Query("A").Distinct().AsCount(new[] { "ColumnA", "ColumnB" });
4646

4747
var c = Compile(query);
4848

QueryBuilder/Query.Aggregate.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
using System.Collections.Generic;
12
using System.Linq;
23

34
namespace SqlKata
45
{
56
public partial class Query
67
{
7-
public Query AsAggregate(string type, params string[] columns)
8+
public Query AsAggregate(string type, string[] columns = null)
89
{
910

1011
Method = "aggregate";
@@ -13,15 +14,15 @@ public Query AsAggregate(string type, params string[] columns)
1314
.AddComponent("aggregate", new AggregateClause
1415
{
1516
Type = type,
16-
Columns = columns.ToList()
17+
Columns = columns?.ToList() ?? new List<string>(),
1718
});
1819

1920
return this;
2021
}
2122

22-
public Query AsCount(params string[] columns)
23+
public Query AsCount(string[] columns = null)
2324
{
24-
var cols = columns.ToList();
25+
var cols = columns?.ToList() ?? new List<string> { };
2526

2627
if (!cols.Any())
2728
{
@@ -33,7 +34,7 @@ public Query AsCount(params string[] columns)
3334

3435
public Query AsAvg(string column)
3536
{
36-
return AsAggregate("avg", column);
37+
return AsAggregate("avg", new string[] { column });
3738
}
3839
public Query AsAverage(string column)
3940
{
@@ -42,17 +43,17 @@ public Query AsAverage(string column)
4243

4344
public Query AsSum(string column)
4445
{
45-
return AsAggregate("sum", column);
46+
return AsAggregate("sum", new[] { column });
4647
}
4748

4849
public Query AsMax(string column)
4950
{
50-
return AsAggregate("max", column);
51+
return AsAggregate("max", new[] { column });
5152
}
5253

5354
public Query AsMin(string column)
5455
{
55-
return AsAggregate("min", column);
56+
return AsAggregate("min", new[] { column });
5657
}
5758
}
5859
}

SqlKata.Execution/Helper.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

SqlKata.Execution/PaginationResult.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Data;
34
using System.Threading.Tasks;
4-
using SqlKata;
55

66
namespace SqlKata.Execution
77
{
@@ -66,29 +66,29 @@ public Query NextQuery()
6666
return this.Query.ForPage(Page + 1, PerPage);
6767
}
6868

69-
public PaginationResult<T> Next()
69+
public PaginationResult<T> Next(IDbTransaction transaction = null, int? timeout = null)
7070
{
71-
return this.Query.Paginate<T>(Page + 1, PerPage);
71+
return this.Query.Paginate<T>(Page + 1, PerPage, transaction, timeout);
7272
}
7373

74-
public async Task<PaginationResult<T>> NextAsync()
74+
public async Task<PaginationResult<T>> NextAsync(IDbTransaction transaction = null, int? timeout = null)
7575
{
76-
return await this.Query.PaginateAsync<T>(Page + 1, PerPage);
76+
return await this.Query.PaginateAsync<T>(Page + 1, PerPage, transaction, timeout);
7777
}
7878

7979
public Query PreviousQuery()
8080
{
8181
return this.Query.ForPage(Page - 1, PerPage);
8282
}
8383

84-
public PaginationResult<T> Previous()
84+
public PaginationResult<T> Previous(IDbTransaction transaction = null, int? timeout = null)
8585
{
86-
return this.Query.Paginate<T>(Page - 1, PerPage);
86+
return this.Query.Paginate<T>(Page - 1, PerPage, transaction, timeout);
8787
}
8888

89-
public async Task<PaginationResult<T>> PreviousAsync()
89+
public async Task<PaginationResult<T>> PreviousAsync(IDbTransaction transaction = null, int? timeout = null)
9090
{
91-
return await this.Query.PaginateAsync<T>(Page - 1, PerPage);
91+
return await this.Query.PaginateAsync<T>(Page - 1, PerPage, transaction, timeout);
9292
}
9393

9494
public PaginationIterator<T> Each

SqlKata.Execution/Query.AggregateExtensions.Async.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

SqlKata.Execution/Query.AggregateExtensions.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)