DapperLib / DapperLib/Dapper

Dapper on ODBC - IN statement

Open
#728 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

I am using Dapper connecting to an ODBC drive via OleDb.

Since this stack overflow post: http://stackoverflow.com/questions/38527197/dapper-where-in-statement-with-odbc it is possible to pass a list as a named parameter which is great :)

However I still have an issue passing a set of parameters that include a list.

Let me give you an example:

This works:

sql = @"select 1 from dual where 1 = ?id1? and 2 = ?id2?"
conn.Query<int>(sql, new { id1 = 1, id2 = 2 });

This works:

sql = @"select 1 from dual where 1 in ?ids?";
conn.Query<int>(sql, new {ids = new[]{1, 2}});

But this throws an AccessViolationException:

sql = @"select 1 from dual where 1 = ?id1? and 2 in ?ids?";
conn.Query<int>(sql, new { id1 = 1, ids = new[] { 1, 2 } });

The description of the exception is: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Is this expected behaviour from Dapper? And if yes, why and how to go around it?

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 repository files or tests are named in the issue. Start by reproducing the two-parameter and mixed scalar/list queries through the shown Dapper Query entry point, then inspect how list parameters are expanded for ODBC/OleDb; done means identifying whether the AccessViolationException is caused by Dapper and documenting or validating a supported workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.