IDataReader.GetRowParser<string>() throws exception
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
Using .NET Core 6
Dapper v 2.0.123
using Dapper;
using Microsoft.Data.SqlClient;
using var connection = new SqlConnection("Server=localhost;Database=Test;Integrated Security=True;Encrypt=False");
var reader = connection.ExecuteReader("select 'test' as col");
var rowParser = reader.GetRowParser<string>();
reader.Read();
string result = rowParser(reader);
Throws exception:
System.InvalidCastException: 'Unable to cast object of type 'System.Func`2[System.Data.IDataReader,System.Object]' to type 'System.Func`2[System.Data.IDataReader,System.String]'.'
reader.GetRowParser<object>(typeof(string))
works, but then extra unboxing is needed: string result = (string)rowParser(reader)
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 with the IDataReader.GetRowParser() call shown in the reproduction and compare it with the working GetRowParser(typeof(string)) overload. Verify the behavior against the provided SQL reader example; done means the generic string parser can be invoked without an InvalidCastException or extra unboxing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100