Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Dapper support an unknown number of result sets?

Tags:

c#

ado.net

dapper

Update:

As Marc noted below, my fundamental question is: What happens when Read() gets called more times than there are record sets when using QueryMultiple()?


I'm working on converting an existing DB call from using SqlDataReader to Dapper.

Having problems with it though. I call a sproc, which conditionally can call 1-4 more sprocs. So I an potentially have many results sets. To simplify my explanation, lets assume I only have 1-2 result set(s). If the first sproc isn't called, but the second sproc IS called then my first Read() call eats up the first and only result set. Then I have a bunch of useless TeamItem objects that were supposed to be ProjectItem objects. Then of course it blows up on the second call to Read() because there isn't another result set.

Am I missing something about Dapper, or is this an extreme case that Dapper just won't be able to support feasibly?

if (_searchParams.WillSearchTeams)
{
    var teams = multi.Read<TeamItem>().ToList();
}
var projects = multi.Read<ProjectItem>().ToList();
like image 813
Mike Haas Avatar asked Jan 26 '13 07:01

Mike Haas


1 Answers

I assume you're already using QueryMultiple; it sounds like the fundamental question here is what happens when you call Read more times than there are grids. I suppose it could return an empty sequence, but I suspect some kind of TryRead would be preferable. No, it doesn't have tht currently - but it could in theory.

like image 77
Marc Gravell Avatar answered Nov 03 '22 10:11

Marc Gravell