Get the count of resultsets/Tables returned from dapper .QueryMultiple Method

c# dapper visual-studio

Question

While using Dapper for multiple Query:

 var result = sqlConnection.QueryMultiple(query, Parameters, commandType: commandType);

How can i get the table count returned from query? It has two overloaded implementation of .Read() method, which each time called, moves to next available result set (No result.Count() property). Eventually i want to put that number in a loop to iterate as many time as number of tables returned from query.

Accepted Answer

`

var reader = this.DbConnection.QueryMultipleAsync(sql, Params, commandType: CommandType.StoredProcedure).Result;

if(reader.IsConsumed == false)
        {
            DeviceTypeReport = reader?.ReadAsync<dynamic>().Result;
        }

`

This is probably what you are looking for hope it helps.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why