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