您的 SQL 语法错误,用于 .net 的 mysql 连接器

店铺流程:


CREATE DEFINER=`newdb`@`%` PROCEDURE `GetMaximumIDsCount`(IN AppID INT,IN isBurnCenter INT,IN BurnCenterID INT)

BEGIN


    IF isBurnCenter = 1 THEN


    SELECT MAX(CAST(b.hospitalid AS SIGNED))


    FROM tblhosipital b


    WHERE b.appId = AppID AND b.burncenterid IS NULL;


    END IF;



    IF isBurnCenter = 0 THEN


    SELECT MAX(CAST(h.hospitalid AS SIGNED))


    FROM tblhosipital h


    WHERE h.appId = AppID AND h.burncenterid <> '' AND h.burncenterid = BurnCenterID;


    END IF;

END

从 ApplicationDbContext 调用(代码优先)


public virtual ObjectResult<long?> GetMaximumIDsCount2(Nullable<int> appID, Nullable<int> isBurnCenter, Nullable<int> burnCenterID)

        {

            var appIDParameter = appID.HasValue ?

                new ObjectParameter("AppID", appID) :

                new ObjectParameter("AppID", typeof(int));


            var isBurnCenterParameter = isBurnCenter.HasValue ?

                new ObjectParameter("isBurnCenter", isBurnCenter) :

                new ObjectParameter("isBurnCenter", typeof(int));


            var burnCenterIDParameter = burnCenterID.HasValue ?

                new ObjectParameter("BurnCenterID", burnCenterID) :

                new ObjectParameter("BurnCenterID", typeof(int));


            return ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreQuery<Nullable<long>>("GetMaximumIDsCount @AppID, @isBurnCenter, @BurnCenterID", appIDParameter, isBurnCenterParameter, burnCenterIDParameter);

        }

获取异常:


您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的“GetMaximumIDsCount @AppID、@isBurnCenter、@BurnCenterID”附近使用的正确语法


梦里花落0921
浏览 113回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP