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
最佳答案
using(var multi = connection.QueryMultiple("check_form_databases", args,
commandType: CommandType.StoredProcedure))
{
int fuelTypes = multi.ReadSingle<int>();
int cityCount = multi.ReadSingle<int>();
// ...
}
注意:如果您正在读取单个值,如果您愿意的话,通常可以将这些值放入单个网格的单个行中的列中。
关于c# - 如何使用返回多个值的存储过程在C#中编写dapper?我想为下面提到的SP写dapper,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44780906/