DapperLib / DapperLib/Dapper

”where in“ parameter splicing problem

Open
#1,636 2 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

Parameter 'sqlParams111' has already been defined."

demo as follows:

//test_01 and test_11 only contain two fields id and addtime
try
{
    using (var conn = new MySqlConnection(connStr))
    {
        conn.Open();
        var ids1 = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
        var ids2 = new List<int> { 1, 20, 18, 17 };
		
        var sql = @"
                select addtime from test_01 where id in @sqlParams1
                union all 
                select addtime from test_11 where id in @sqlParams11";
				
        var res = conn.Query<DateTime>(sql, new { sqlParams1 = ids1, sqlParams11 = ids2 }).ToList();
        res.ForEach(s => Console.WriteLine(s));
        Console.ReadKey();
    }
}
catch (Exception ex)
{
    throw;
}

03

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 source file or test is named. Start by reproducing the supplied C# query with two differently named IN parameters, then trace Dapper's parameter-splicing path for collection parameters. Done means both collections execute without the duplicate-parameter error and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.