DapperLib / DapperLib/Dapper.Contrib

Dapper should expose a .Count<T>() method

Open
#138 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
293
Forks
109
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing Get and GetAll implementations and how TableAttribute is handled. Add a Count() extension on IDbConnection that uses the mapped table name and returns the row count; done means the method is exposed consistently with the other extensions.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
database
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.