程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> IBatisNet系列-執行存儲過程

IBatisNet系列-執行存儲過程

編輯:.NET實例教程


映射XML文件書寫如下


<?XML version="1.0" encoding="utf-8" ?>

<sqlMap namespace="Member" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SqlMap.xsd">
    <resultMaps>
        <resultMap id="SelectResult" class="PlatAdmin.Model.Member">
            <result property="Id" column="id" />
            <result property="Identityno" column="identityno" />
            <result property="Telephone" column="telephone" />
            <result property="Email" column="email" />
            <result property="Linktel" column="linktel" />
            <result property="Address" column="address" />
            <result property="Content" column="content" />
            <result property="Username" column="username" />
            <result property="Password" column="passWord" />
            <result property="Truename" column="truename" />
            <result property="Enable" column="enable" />
            <result property="Regdate" column="regdate" />
        </resultMap>
    </resultMaps>
        
    <parameterMaps>
        <parameterMap id="swapParas" class="PlatAdmin.Model.Member">
            <parameter property="querystr" column="" />
            <parameter property="keyfIEld" column="" />
            <parameter property="pagesize" column="" />
            <parameter property="pagenumber" column="" />
        </parameterMap>
    </parameterMaps>
    
    <statements>
        <procedure id="GetMemberList" parameterMap="swapParas" resultMap="SelectResult">
        &nbsp;   usp_GetRecordset
        </procedure>

        
    </statements>
</sqlMap>
 程序代碼如下:


public IList GetMemberList(string querystr,int pageNo)
        {
            Hashtable ht = new Hashtable();
            ht.Add("querystr",querystr);
            ht.Add("keyfIEld","id");
            ht.Add("pagesize",2);
            ht.Add("pagenumber",pageNo);

            SqlMapper sqlMap = IBatisNet.DataMapper.Mapper.Instance();

            try
            {
                return sqlMap.QueryForList("GetMemberList",ht);
            }
            catch(Exception e)
            {
                throw new IBatisNetException(e.Message,e);
            }
        }

出處:福娃瑩瑩 BLOG

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved