Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit c313f7c

Browse files
committed
Merge pull request #377 from angelcolmenares/master
Update OrmLiteCountTests.cs
2 parents 3951553 + 8c2d584 commit c313f7c

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

src/ServiceStack.OrmLite.MySql.Tests/Expressions/OrmLiteCountTests.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,24 @@ public void CanDoCountWithInterfaceAndPredicate()
6464
}
6565
}
6666

67-
long Count<T>(IDbConnection db) where T : IHasId<int>, new()
67+
long Count<T>(IDbConnection db) where T : IHasId<int>
6868
{
69-
T request = new T();
70-
return db.Scalar<T, long>(e => Sql.Count(request.Id));
69+
return db.Scalar<T, long>(e => Sql.Count(e.Id));
7170
}
7271

7372

74-
long CountByColumn<T>(IDbConnection db) where T : IHasCountColumn, new()
73+
long CountByColumn<T>(IDbConnection db) where T : IHasCountColumn
7574
{
76-
T request = new T();
77-
return db.Scalar<T, long?>(e => Sql.Count(request.CountColumn)).Value;
75+
return db.Scalar<T, long?>(e => Sql.Count(e.CountColumn)).Value;
7876
}
7977

8078

81-
int Count<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasId<int>, new()
79+
int Count<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasId<int>
8280
{
8381
return db.Scalar<T, int>(e => Sql.Count(e.Id), predicate);
8482
}
8583

86-
int CountByColumn<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasCountColumn, new()
84+
int CountByColumn<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasCountColumn
8785
{
8886
return db.Scalar<T, int?>(e => Sql.Count(e.CountColumn), predicate).Value;
8987
}
@@ -109,4 +107,4 @@ public CountTestTable() { }
109107
public int? CountColumn { get; set; }
110108
#endregion
111109
}
112-
}
110+
}

src/ServiceStack.OrmLite.PostgreSQL.Tests/Expressions/OrmLiteCountTests.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,24 @@ public void CanDoCountWithInterfaceAndPredicate()
6565
}
6666
}
6767

68-
long Count<T>(IDbConnection db) where T : IHasId<int>, new()
68+
long Count<T>(IDbConnection db) where T : IHasId<int>
6969
{
70-
T request = new T();
71-
return db.Scalar<T, long>(e => Sql.Count(request.Id));
70+
return db.Scalar<T, long>(e => Sql.Count(e.Id));
7271
}
7372

7473

75-
long CountByColumn<T>(IDbConnection db) where T : IHasCountColumn, new()
74+
long CountByColumn<T>(IDbConnection db) where T : IHasCountColumn
7675
{
77-
T request = new T();
78-
return db.Scalar<T, long?>(e => Sql.Count(request.CountColumn)).Value;
76+
return db.Scalar<T, long?>(e => Sql.Count(e.CountColumn)).Value;
7977
}
8078

8179

82-
int Count<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasId<int>, new()
80+
int Count<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasId<int>
8381
{
8482
return db.Scalar<T, int>(e => Sql.Count(e.Id), predicate);
8583
}
8684

87-
int CountByColumn<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasCountColumn, new()
85+
int CountByColumn<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasCountColumn
8886
{
8987
return db.Scalar<T, int?>(e => Sql.Count(e.CountColumn), predicate).Value;
9088
}
@@ -110,4 +108,4 @@ public CountTestTable() { }
110108
public int? CountColumn { get; set; }
111109
#endregion
112110
}
113-
}
111+
}

src/ServiceStack.OrmLite.SqlServerTests/Expressions/OrmLiteCountTests.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,24 @@ public void CanDoCountWithInterfaceAndPredicate()
6363
}
6464
}
6565

66-
long Count<T>(IDbConnection db) where T : IHasId<int>, new()
66+
long Count<T>(IDbConnection db) where T : IHasId<int>
6767
{
68-
T request = new T();
69-
return db.Scalar<T, long>(e => Sql.Count(request.Id));
68+
return db.Scalar<T, long>(e => Sql.Count(e.Id));
7069
}
7170

7271

73-
long CountByColumn<T>(IDbConnection db) where T : IHasCountColumn, new()
72+
long CountByColumn<T>(IDbConnection db) where T : IHasCountColumn
7473
{
75-
T request = new T();
76-
return db.Scalar<T, long?>(e => Sql.Count(request.CountColumn)).Value;
74+
return db.Scalar<T, long?>(e => Sql.Count(e.CountColumn)).Value;
7775
}
7876

7977

80-
int Count<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasId<int>, new()
78+
int Count<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasId<int>
8179
{
8280
return db.Scalar<T, int>(e => Sql.Count(e.Id), predicate);
8381
}
8482

85-
int CountByColumn<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasCountColumn, new()
83+
int CountByColumn<T>(IDbConnection db, Expression<Func<T, bool>> predicate) where T : IHasCountColumn
8684
{
8785
return db.Scalar<T, int?>(e => Sql.Count(e.CountColumn), predicate).Value;
8886
}
@@ -108,4 +106,4 @@ public CountTestTable() { }
108106
public int? CountColumn { get; set; }
109107
#endregion
110108
}
111-
}
109+
}

0 commit comments

Comments
 (0)