TypeHandler not invoked on List Parameters
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
Hi there,
I'm trying to use Dapper List Parameter with TypeHandler for Guid Management in Oracle ( represented as RAW(16) ) but it is not working as expected (Dapper version 2.1.4).
I'm using a GuidTypeHandler like the one generated by your AI support:
public class GuidTypeHandler : SqlMapper.TypeHandler<Guid>
{
public override Guid Parse(object value)
{
// Implement logic to parse the Guid value from the database
// For example:
if (value is byte[] bytes)
{
return new Guid(bytes);
}
throw new InvalidOperationException("Invalid Guid value");
}
public override void SetValue(IDbDataParameter parameter, Guid value)
{
// Implement logic to set the Guid value for the database parameter
// For example:
parameter.Value = value.ToByteArray();
parameter.DbType = DbType.Binary;
}
}
and I registered it as follows:
SqlMapper.AddTypeHandler(new GuidTypeHandler());
I have no problem with a single parameter such as
var res = conn.QuerySingle<Guid>("SELECT ID FROM TEST WHERE ID = :Id", new { Id = id });
but the type handler is not invoked like expected on List Parameters
var res = conn.Query<Guid>("SELECT ID FROM TEST WHERE ID IN :Ids", new { Ids = new List<Guid> { id1, id2 }}).ToList();
so I get the Oracle error Value does not fall within the expected range.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Oracle query with the registered GuidTypeHandler, comparing the working single parameter with list parameter expansion. Trace the list-parameter path and TypeHandler invocation; done means each Guid in Ids is bound compatibly with Oracle RAW(16) and the query returns the expected rows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100