I'm doing the following query using dapper and C#7 ValueTuples (installed nuget):
await connection.QueryAsync<(int, Guid)>(
$@"SELECT tenant, pid FROM Table
ORDER BY id
OFFSET {skip} ROWS
FETCH NEXT {dbBatchSize} ROWS ONLY");
It returns a list of 0 and Guid.Empty.
If I use only int or only Guid it works ok
I also tried naming the ValueTuple according to the columns in the table:
await connection.QueryAsync<(int tenant, Guid pid)>("...")
Same result.
Anyone has any tip? Thanks in advance!
This is a known limitation of dapper. It doesn't support copying a query result into a ValueTuple. There is an open issue on Github requesting support for this.
The OP of that request creating a working example of how it could be done in April and it is currently scheduled for the v2.0 release.
Dapper seems to support ValueTuple query mappings since v.1.50.4, although the issue David Arno pointed out is still open. We've been utilizing this feature for a while in our projects.
I'm unable to find any mentions of added support in release notes either, but I managed to find an example usage of this feature in Dapper's test project.