Get the count of resultsets returned from dapper.QueryMultiple Method

2k Views Asked by At

I use Dapper library. I have a dynamic query which returns one or more resultsets/tables from QueryMultiple Method. I don't have any specific count of resultsets to write no. of Read() method. Do we have any function or method (e.g. result.Count = no. of return tables) or how many no. of times can we write read() to retrieve N no. of resultsets?

SqlMapper.GridReader result = _connection.QueryMultipleAsync(model.APIName, oPara, commandType: CommandType.StoredProcedure).Result;

dynamic dyn = result.Read();
1

There are 1 best solutions below

0
Alex On BEST ANSWER

Dapper currently doesn't have a count of the available result sets in the GridReader.

But you can use the IsConsumed property instead. Once all result sets are processed, IsConsumed is set to true.

while (!result.IsConsumed)
{
   dynamic rs = result.Read();
}