映射xml文件书写如下
<?xml version="1.0" binding="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" columns="id" />
<result property="Identityno" Column="identityno" />
<result property="Telephone" Column="Telephone" />
<result property="Email" columns="email" />
<result property="Linktel" Column="linktel" />
<result property="Address" columns="address" />
<result property="Content" columns="content" />
<result property="Benutzername" spalte="Benutzername" />
<result property="Password" Column="password" />
<result property="Truename" columns="truename" />
<result property="Enable" columns="enable" />
<result property="Regdate" Column="regdate" />
</resultMap>
</resultMaps>
<parameterMaps>
<parameterMap id="swapParas" class="PlatAdmin.Model.Member">
<parameter property="querystr" columns="" />
<parameter property="keyfield" columns="" />
<parameter property="pagesize" columns="" />
<parameter property="pagenumber" columns="" />
</parameterMap>
</parameterMaps>
<Anweisungen>
<procedure id="GetMemberList" parameterMap="swapParas" resultMap="SelectResult">
usp_GetRecordset
</procedure>
</statements>
</sqlMap>
程序代码如下:
öffentliche 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();
versuchen
{
return sqlMap.QueryForList("GetMemberList",ht);
}
Catch (Ausnahme e)
{
throw new IBatisNetException(e.Message,e);
}
}
出处:福娃莹莹 BLOG