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

Commit 8c2d584

Browse files
Update OrmLiteCountTests.cs
fix methods "long Count(IDbConnection db)" and "long CountByColumn(IDbConnection db)"
1 parent 8901b28 commit 8c2d584

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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)