DapperLib / DapperLib/Dapper

API Proposal - example code included

Open
#2,137 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

public static class ProposalExtensions
    {
        public static void JustShowMeTheCode(IDbConnection cn)
        {
            var result = cn.Query(
                // allows to use anonymous type as result
                template: new { EmployeeName = "" }, 
                param: new { EmployeeAge = 26 },
                // allows to use 'nameof' for column names and parameter names 
                sql: (t, p) => $"select e.name as {nameof(t.EmployeeName)} from tbl_emp e where e.age>@{nameof(p.EmployeeAge)}");
            foreach (var item in result)
            {
                Console.WriteLine(item.EmployeeName);
            }
        }

        public static IEnumerable<T> Query<T,TParams>(this IDbConnection cnn, T template, Func<T,TParams,string> sql, TParams param,  IDbTransaction? transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
        {
            return cnn.Query<T>(sql(default(T),default(TParams)),param,transaction,buffered,commandTimeout,commandType);
        }

        public static IEnumerable<T> Query<T>(this IDbConnection cnn, T template, Func<T,string> sql, IDbTransaction? transaction = null, bool buffered = true, int? commandTimeout = null, CommandType? commandType = null)
        {
            return cnn.Query<T>(sql(default(T)), param:null, transaction, buffered, commandTimeout, commandType);
        }
    }

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 reviewing the IDbConnection Query extension examples shown in the issue and the proposed overload signatures. The issue does not name repository files, tests, or acceptance criteria, so clarify the intended API and expected behavior before identifying an implementation location or defining what done means.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.