CREATE DEFINER=`training`@`%` PROCEDURE `check_form_databases`(
in fuel_id int,
in city_id int,
in color_id int,
in make_id int,
in model_id int,
in version_id int,
out fuel_id_count int,
out city_id_count int,
out color_id_count int,
out make_id_count int,
out model_id_count int,
out version_id_count int
)
BEGIN
select count(CarFuelTypeId) into fuel_id_count from carfueltypes where CarFuelTypeId = fuel_id;
select count(cities.ID) into city_id_count from cities where cities.ID = city_id;
select count(carcolors.ID) into color_id_count from carcolors where carcolors.ID = color_id;
select count(carmakes.ID) into make_id_count from carmakes where carmakes.ID = make_id;
select count(carmodels.ID) into model_id_count from carmodels where carmodels.ID = model_id;
select count(carversions.ID) into version_id_count from carversions where carversions.ID = version_id;
END
Asked
Active
Viewed 436 times
1

stuartd
- 70,509
- 14
- 132
- 163

Ashu Udeniya
- 73
- 1
- 4
-
See if [this](https://stackoverflow.com/questions/6317937/dapper-net-and-stored-proc-with-multiple-result-sets) works on mySql – stuartd Jun 27 '17 at 13:03
-
Please include your question in the post body, and not only in the title. – ItamarG3 Jun 27 '17 at 13:26
-
A much easier solution IMO would be to put those into variables and then select a recordset of variables into an object (replace $ with @...SO is restricting me): select $countCarFultType = count(CarFuelTypeID)...select $countCities = count(*) ...[etc. etc.] and then end with a single one-row query with your properties: select $CountCarFuelType AS CountCarFuleType, $countCities AS CountCities. Then just map to an object with those properties. You wouldn't need the 'out' parameters either, cleaning that up. – BlackjacketMack Jun 29 '17 at 17:17
1 Answers
1
using(var multi = connection.QueryMultiple("check_form_databases", args,
commandType: CommandType.StoredProcedure))
{
int fuelTypes = multi.ReadSingle<int>();
int cityCount = multi.ReadSingle<int>();
// ...
}
Note: if you're reading single values, it is usually possible to put those into columns on a single row of a single grid, if you prefer.

Marc Gravell
- 1,026,079
- 266
- 2,566
- 2,900