iBATIS.NET执行存储过程实例详解

开发 后端
iBATIS.NET执行存储过程是什么情况呢?iBATIS.NET执行存储过程是怎么执行的呢?那么本文就通过实例向你详细介绍。

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进行单元测试浅析
责任编辑:仲衡 来源: CSDN博客
相关推荐

2009-07-21 13:50:00

iBATIS.NET调

2009-07-22 09:07:01

iBATIS.NET

2009-07-20 13:22:47

iBATIS.Net日

2009-07-16 13:50:31

ibatisResultMap

2009-07-20 14:56:18

iBATIS.NET动态选择DAO

2009-07-20 10:06:07

iBATIS.net查询方式

2009-07-22 14:28:52

iBATIS.NET配

2009-07-20 09:51:19

iBATIS.net数据库缓存

2009-07-22 14:11:09

配置ibatis.neiBatis.net配

2009-07-21 15:21:59

iBATIS.NET多

2009-07-20 15:14:44

iBATIS.NET连

2011-03-15 13:30:27

IBatis.netMySQL

2009-07-17 17:57:20

NPetShop iBATIS.Net

2009-07-20 13:47:08

iBATIS.NET字

2009-07-21 14:15:00

iBATIS.NET多

2009-07-20 15:27:22

Castle.DynaiBATIS.NET

2009-07-21 14:57:41

iBatis中调用存储iBatis

2009-07-21 16:17:28

iBATIS.NET

2009-07-21 16:30:15

iBATIS.NET与单元测试

2009-07-20 09:27:42

IBATIS.netDAO
点赞
收藏

51CTO技术栈公众号