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

Commit 9c33657

Browse files
Update OrmLiteCountTests.cs
fix methods "long Count<T>(IDbConnection db)" and "long CountByColumn<T>(IDbConnection db)" to build right sql sentence
1 parent 102f03d commit 9c33657

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tests/ServiceStack.OrmLite.SqliteTests/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+
}

0 commit comments

Comments
 (0)