zoukankan      html  css  js  c++  java
  • 创建带输入参数的存储过程

    CREATE PROCEDURE proc_CountSiteGroupByStructure
    -- Add the parameters for the stored procedure here
    @structureType int  --传递参数
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    select a.Name,CountNum=(select Count(*) from Com_SiteGroup c where c.Com_StructureID=a.Com_StructureID )
    from Com_Structure a inner join Com_StructureType b on a.Com_SructureTypeID=b.Com_StructureTypeID
    and b.Type=@structureType and a.ParentStructureID!='00000000-0000-0000-0000-000000000000'
    END
    GO

    //使用orm调用带参数的存储过程

    var dr = DataAccess.LepulsDB.DBContext.StoredProcedure("proc_CountSiteGroupByStructure").AddInputParameter("@structureType", System.Data.DbType.Int16, (int)StructureTypeGenus.Company).ToDataReader();
    List<SiteGroupEchartModel> list = new List<SiteGroupEchartModel>();
    while(dr.Read())
    {
    SiteGroupEchartModel model = new SiteGroupEchartModel();
    model.nameX = dr["SiteTypeName"].ToString();
    model.valueY = Convert.ToInt32(dr["CountNum"]);
    list.Add(model);
    }
    return list;

  • 相关阅读:
    个人博客作业Week2
    个人作业
    软件工程——个人博客作业三
    软工个人博客二
    软件工程——个人博客作业一
    Linux服务器搭建常用环境(一)
    Swift学习之语言基础
    Python——函数的参数
    Python——函数的调用
    Python 导语
  • 原文地址:https://www.cnblogs.com/redfull/p/6762105.html
Copyright © 2011-2022 走看看