DapperLib / DapperLib/Dapper

QueryMultiple on sproc with 4 result sets reading too much data on second Read command

Open
#272 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-investigation
Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

I am using Mono v3.12.1 and Dapper v1.40.

I have a stored proc that returns 4 result sets. My code is using a QueryMultiple followed by 4 different foreach loops using unbuffered Read commands. It seems to detect when the first result set ends and moves on to the second one, but then continues to retrieve all of the remaining data from result sets 2-4 via the second foreach loop, and when it gets to the third loop, an ObjectDisposedException is thrown with message: The reader has been disposed; this can happen after all data has been consumed

The code is basically the same as what you have in the documentation at the link below. The only difference is that I'm streaming the data unbuffered using foreach loops (so no .Single or .ToList, although it breaks when I do that as well) and I'm using a SQL Server stored proc instead of inline SQL.
https://github.com/StackExchange/dapper-dot-net#multiple-results

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

Start with the QueryMultiple entry point and the unbuffered Read calls described in the issue, using the linked multiple-results documentation as the expected usage. Reproduce the stored procedure case with four result sets and compare each foreach loop's consumption; done means every result set is read separately without consuming later sets or disposing the reader before the third loop.

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
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.