惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
爱范儿
爱范儿
GbyAI
GbyAI
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
C
Check Point Blog
H
Help Net Security
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
Y
Y Combinator Blog
U
Unit 42
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - Kangaroo

IList<T>与Xml互相转换 jQTreeTable在Asp.net中的应用 通用附件上传方法 window.createPopup()创建菜单 - Kangaroo - 博客园 客户端全部选中或取消DataGrid中的CheckBox 事务的回滚设置(SET XACT_ABORT) 获取所有命名的服务器变量的名称和值 服务端返回操作结果消息的方法 - Kangaroo - 博客园 Treeview的文件目录配置 - Kangaroo - 博客园 用层(DIV)来实现弹出窗口 一个实用的表格(锁定表头,可调整单元格大小,可排序) showModalDialog()、showModelessDialog()方法使用详解 SQL Server .NET Framework 数据提供程序连接池 iBATIS.NET 学习笔记(十一) iBATIS.NET 学习笔记(九) iBATIS.NET 学习笔记(八) iBATIS.NET 学习笔记(七) iBATIS.NET 学习笔记(六) iBATIS.NET 学习笔记(五)
iBATIS.NET 学习笔记(十)
Kangaroo · 2006-07-20 · via 博客园 - Kangaroo

Data Map (.NET):
Example:

<?xml version="1.0" encoding="UTF-8" ?>
  
<sqlMap namespace="Product" 
xmlns
="http://ibatis.apache.org/mapping" 
xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance" >

  
<alias>
    
<typeAlias alias="Product" type="Example.Domain.Product, Example.Domain" />
  
</alias>

  
<!-- keeps the result of the last one thousand of these queries in active memory for up to 24 hours-->
  
<cacheModels>
    
<cacheModel id="productCache" type="LRU">
      
<flushInterval hours="24"/>
      
<property name="CacheSize" value="1000" />
    
</cacheModel>
  
</cacheModels>

   
<!--maps the columns to our object properties-->
   
<resultMaps>
    
<resultMap id="productResult" class="Product">
      
<result property="Id" column="Product_Id"/>
      
<result property="Description" column="Product_Description"/>
    
</resultMap>
   
</resultMaps>

  
<statements>
    
<select id="GetProduct" parameterMap="productParam" cacheModel="productCache">
      select * from Products where Product_Id = ?
    
</select>
  
</statements>

  
<!--maps the SQL "?" to the product Id property-->
  
<parameterMaps>
    
<parameterMap id="productParam" class="Product">
      
<parameter property="Id"/>
    
</parameterMap>
  
<parameterMaps>

</sqlMap>

Mapped Statements
Mapped Statements can hold any SQL statement and can use Parameter Maps and Result Maps for input and output. (A stored procedure is a specialized form of a statement.)

Statement element syntax
<statement id="statement.name"
  [parameterMap
="parameterMap.name"]
  [parameterClass
="alias"]
  [resultMap
="resultMap.name"]
  [resultClass
="class.name|alias"]
  [listClass
="class.name|alias"]
  [cacheModel
="cache.name"]
>
  select * from Products where Product_Id = [?|#propertyName#]
  order by [$simpleDynamic$]
</statement>

[]中的参数是可选项。
下面是6种Statement-type 元素

Statement Element Attributes Child Elements Methods
<statement>
id
            parameterClass
            resultClass
            listClass
            parameterMap
            resultMap
            cacheModel
All dynamic elements
Insert
            Update
            Delete
            All query methods
<insert>
id
            parameterClass
            parameterMap
All dynamic elements
            <selectKey>
            <generate>
Insert
            Update
            Delete 
<update>
id
            parameterClass
            parameterMap
            extends
All dynamic elements
            <generate>
Insert
            Update
            Delete
<delete>
id
            parameterClass
            parameterMap
            extends
All dynamic elements
            <generate>
Insert
            Update
            Delete
<select>
id
            parameterClass
            resultClass
            listClass
            parameterMap
            resultMap
            cacheModel
            extends
All dynamic elements
            <generate>
All query methods
<procedure>
id
            parameterMap
            resultClass
            resultMap
            cacheModel
All dynamic elements 
Insert
            Update
            Delete
            All query methods