iBATIS.NET执行存储过程实例详解
创始人
2024-04-18 22:31:21
0

iBATIS.NET执行存储过程是怎么进行的呢?那么我们就开始我们的讲解:

首先我们看看XML的配置,映射XML文件书写如下

  1. ﹤?xml version="1.0" encoding="utf-8" ?﹥  
  2.  
  3. ﹤sqlMap namespace="Member" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SqlMap.xsd"﹥  
  4.     ﹤resultMaps﹥  
  5.         ﹤resultMap id="SelectResult" class="PlatAdmin.Model.Member"﹥  
  6.             ﹤result property="Id" column="id" /﹥  
  7.             ﹤result property="Identityno" column="identityno" /﹥  
  8.             ﹤result property="Telephone" column="telephone" /﹥  
  9.             ﹤result property="Email" column="email" /﹥  
  10.             ﹤result property="Linktel" column="linktel" /﹥  
  11.             ﹤result property="Address" column="address" /﹥  
  12.             ﹤result property="Content" column="content" /﹥  
  13.             ﹤result property="Username" column="username" /﹥  
  14.             ﹤result property="Password" column="password" /﹥  
  15.             ﹤result property="Truename" column="truename" /﹥  
  16.             ﹤result property="Enable" column="enable" /﹥  
  17.             ﹤result property="Regdate" column="regdate" /﹥  
  18.         ﹤/resultMap﹥  
  19.     ﹤/resultMaps﹥  
  20.           
  21.     ﹤parameterMaps﹥  
  22.         ﹤parameterMap id="swapParas" class="PlatAdmin.Model.Member"﹥  
  23.             ﹤parameter property="querystr" column="" /﹥  
  24.             ﹤parameter property="keyfield" column="" /﹥  
  25.             ﹤parameter property="pagesize" column="" /﹥  
  26.             ﹤parameter property="pagenumber" column="" /﹥  
  27.         ﹤/parameterMap﹥  
  28.     ﹤/parameterMaps﹥  
  29.       
  30.     ﹤statements﹥  
  31.         ﹤procedure id="GetMemberList" parameterMap="swapParas" resultMap="SelectResult"﹥  
  32.             usp_GetRecordset  
  33.         ﹤/procedure﹥  
  34.  
  35.           
  36.     ﹤/statements﹥  
  37. ﹤/sqlMap﹥ 

iBATIS.NET执行存储过程实例程序代码如下:

  1. public IList GetMemberList(string querystr,int pageNo)  
  2.         {  
  3.             Hashtable ht = new Hashtable();  
  4.             ht.Add("querystr",querystr);  
  5.             ht.Add("keyfield","id");  
  6.             ht.Add("pagesize",2);  
  7.             ht.Add("pagenumber",pageNo);  
  8.  
  9.             SqlMapper sqlMap = IBatisNet.DataMapper.Mapper.Instance();  
  10.  
  11.             try 
  12.             {  
  13.                 return sqlMap.QueryForList("GetMemberList",ht);  
  14.             }  
  15.             catch(Exception e)  
  16.             {  
  17.                 throw new IBatisNetException(e.Message,e);  
  18.             }  
  19.         } 

iBATIS.NET执行存储过程实例的情况就介绍到这里,希望对你有所帮助。

【编辑推荐】

  1. iBATIS教程之like语句的写法浅析
  2. iBATIS.NET多数据库支持浅析
  3. iBATIS教程之如何获得output参数值
  4. iBATIS.NET处理多参数的SQL语句的配置
  5. iBATIS.NET与VS 2005进行单元测试浅析

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
着眼MAC地址,解救无法享受D... 在安装了DHCP服务器的局域网环境中,每一台工作站在上网之前,都要先从DHCP服务器那里享受到地址动...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...