在.netCore里使用SqlSugar调用mysql存储过程

摘自: https://blog.csdn.net/shanshan2099/article/details/120784126

CREATE DEFINER=`root`@`%` PROCEDURE `CalcCompletionPercentByItem`(IN `pitemId` varchar(50),out `c` decimal(15,2))
label:BEGIN
declare taskcnt int;
declare FinishedCnt int;


set taskcnt=(select count(1) from itemtask where ItemId=pitemId and isdelete=0);
  -- select taskcnt;
  -- leave label;
set FinishedCnt =(select count(1) from itemtask where ItemId=pitemId and isdelete=0 and State=2);
if taskcnt=0 then
  set c=0;
  leave label;
end if;
set c=convert(FinishedCnt/taskCnt*100,decimal(15,2));
SELECT c;
END

==================================

.netCore调用:

var pitemId = new SugarParameter("@pitemId", itemId);
  var ReturnV = new SugarParameter("@c", null, true);
  ReturnV.DbType = System.Data.DbType.Decimal;
  await Db.Ado.UseStoredProcedure().SqlQuerySingleAsync<float>("CalcCompletionPercentByItem", pitemId, ReturnV);
  return (decimal)ReturnV.Value;
————————————————
版权声明:本文为CSDN博主「shanshan2099」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/shanshan2099/article/details/120784126

 

posted on 2022-05-08 09:09  manber  阅读(743)  评论(0编辑  收藏  举报

导航