IBatisNet系列-执行存储过程

2008-02-22 09:33:23来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

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

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:.NET正则表达式使用高级技巧之反向引用

下一篇:Repeater读取数据并分页