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

Commit 43807ed

Browse files
Update OrmLiteCountTests.cs
fix methods "long Count(IDbConnection db)" and "long CountByColumn(IDbConnection db)"
1 parent 79927fd commit 43807ed

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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+
}

0 commit comments

Comments
 (0)