Dapper should expose a .Count<T>() method
palenshus opened this issue · 0 comments
palenshus commented
The implementation should be quite simple I believe, similar to how Get or GetAll are implemented. Here's the extension method I've been using:
public static int Count<T>(this IDbConnection connection)
{
return connection.QuerySingle<int>($"SELECT COUNT(1) FROM {typeof(T).Name}");
}
Obviously the real implementation would need to incorporate the TableAttribute