DapperLib / DapperLib/Dapper

Question about @value substitution

Open
#1,231 16 comments 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

Can someone point me to the code that does the substitution of @parameter values? It seems straightforward when we have something in a select SQL string like this:

            WHERE lc.course_id=@CourseId

The @CourseId is replaced with the respective value passed in via our anonymous object - all good.

But what about more complex SQL where it itself is using @parameter syntax ? for example this is the start of a quite involved query that is ultimately a SELECT:

            DECLARE @LearnerID VARCHAR(20) 

            SET @LearnerID = '{0}' 

            DECLARE @EndDate DATETIME 

            SET @EndDate = Cast((SELECT TOP 1 loa_finish_date AS LOAEndDate 
                                 FROM   learner_loa 
                                 WHERE  learner_id = '{1}' 
                                        AND approval_status = 1 
                                 ORDER  BY loa_approval_date DESC) AS DATETIME) 

How does dapper analyze this to separate user defined replacement values from other SQL declarations and assignments that also use @name syntax?

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

No file or test is named, and the issue asks for an explanation rather than a code change. Start by locating Dapper’s parameter-binding entry point and tracing how anonymous-object values are handled alongside SQL variables; done means documenting that distinction clearly with an example covering the shown DECLARE and SET statements.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.