首页 > 编程 > .NET > 正文

IBatisNet系列-执行存储过程

2024-07-21 02:29:24
字体:
来源:转载
供稿:网友

映射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">
            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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表