今天开始尝试着用iBATIS.NET写程序,创建WEB项目IbatisNET.Example,添加引用IBatisNet.DataMapper.dll,IBatisNet.DataAccess.dll,IBatisNet.Common.dll。
实体类Customers.cs
iBATIS.NET 学习笔记(四)//***********************************************************
iBATIS.NET 学习笔记(四)
//*公司:
iBATIS.NET 学习笔记(四)
//*作者:YK
iBATIS.NET 学习笔记(四)
//*模块:IbatisNet.Example.Model
iBATIS.NET 学习笔记(四)
//*功能:
iBATIS.NET 学习笔记(四)
//*创建日期:
iBATIS.NET 学习笔记(四)
//*修改日期:
iBATIS.NET 学习笔记(四)
//***********************************************************
iBATIS.NET 学习笔记(四)
using System;
iBATIS.NET 学习笔记(四)
iBATIS.NET 学习笔记(四)
namespace IbatisNet.Example.Model

对应实体类影射的Customers.XML文件
iBATIS.NET 学习笔记(四)<?xml version="1.0" encoding="utf-8" ?> 
iBATIS.NET 学习笔记(四)
<sqlMap namespace="Customers" xmlns="http://ibatis.apache.org/mapping" 
iBATIS.NET 学习笔记(四)xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance">
iBATIS.NET 学习笔记(四)    
<alias>
iBATIS.NET 学习笔记(四)        
<typeAlias alias="Customers" type="IbatisNet.Example.Model.Customers, IbatisNet.Example" />
iBATIS.NET 学习笔记(四)    
</alias>
iBATIS.NET 学习笔记(四)    
<resultMaps>                                    
iBATIS.NET 学习笔记(四)        
<resultMap id="CustomersResult" class="Customers">
iBATIS.NET 学习笔记(四)            
<result property="CustomerID" column="CustomerID"/>
iBATIS.NET 学习笔记(四)            
<result property="CompanyName" column="CompanyName"/>
iBATIS.NET 学习笔记(四)            
<result property="ContactName" column="ContactName"/>
iBATIS.NET 学习笔记(四)            
<result property="ContactTitle" column="ContactTitle" />
iBATIS.NET 学习笔记(四)            
<result property="Address" column="Address" />
iBATIS.NET 学习笔记(四)            
<result property="City" column="City" />
iBATIS.NET 学习笔记(四)            
<result property="Region" column="Region" />
iBATIS.NET 学习笔记(四)            
<result property="PostalCode" column="PostalCode" />
iBATIS.NET 学习笔记(四)            
<result property="Country" column="Country" />
iBATIS.NET 学习笔记(四)            
<result property="Phone" column="Phone" />
iBATIS.NET 学习笔记(四)            
<result property="Fax" column="Fax" />
iBATIS.NET 学习笔记(四)        
</resultMap>
iBATIS.NET 学习笔记(四)    
</resultMaps>
iBATIS.NET 学习笔记(四)    
<!-- =============================================
iBATIS.NET 学习笔记(四)        MAPPED STATEMENTS 
iBATIS.NET 学习笔记(四)    ============================================= 
iBATIS.NET 学习笔记(四)    
-->
iBATIS.NET 学习笔记(四)    
<statements>
iBATIS.NET 学习笔记(四)  
iBATIS.NET 学习笔记(四)        
<select id="GetAllCustomers" resultMap="CustomersResult" parameterClass="Customers">
iBATIS.NET 学习笔记(四)            select
iBATIS.NET 学习笔记(四)                CustomerID,
iBATIS.NET 学习笔记(四)                CompanyName,
iBATIS.NET 学习笔记(四)                ContactName,
iBATIS.NET 学习笔记(四)                ContactTitle,
iBATIS.NET 学习笔记(四)                Address,
iBATIS.NET 学习笔记(四)                City,
iBATIS.NET 学习笔记(四)                Region,
iBATIS.NET 学习笔记(四)                PostalCode,
iBATIS.NET 学习笔记(四)                Country,
iBATIS.NET 学习笔记(四)                Phone,
iBATIS.NET 学习笔记(四)                Fax 
iBATIS.NET 学习笔记(四)            from Customers
iBATIS.NET 学习笔记(四)        
</select>
iBATIS.NET 学习笔记(四)        
iBATIS.NET 学习笔记(四)        
<insert id="InsertCustomer" parameterClass="Customers">
iBATIS.NET 学习笔记(四)          insert into Customers
iBATIS.NET 学习笔记(四)             (CustomerID,
iBATIS.NET 学习笔记(四)              CompanyName,
iBATIS.NET 学习笔记(四)              ContactName,
iBATIS.NET 学习笔记(四)              ContactTitle,
iBATIS.NET 学习笔记(四)              Address,
iBATIS.NET 学习笔记(四)              City,
iBATIS.NET 学习笔记(四)              Region,
iBATIS.NET 学习笔记(四)              PostalCode,
iBATIS.NET 学习笔记(四)              Country,
iBATIS.NET 学习笔记(四)              Phone,
iBATIS.NET 学习笔记(四)              Fax)
iBATIS.NET 学习笔记(四)          values
iBATIS.NET 学习笔记(四)             (#CustomerID#,
iBATIS.NET 学习笔记(四)              #CompanyName#,
iBATIS.NET 学习笔记(四)              #ContactName#,
iBATIS.NET 学习笔记(四)              #ContactTitle#,
iBATIS.NET 学习笔记(四)              #Address#,
iBATIS.NET 学习笔记(四)              #City#,
iBATIS.NET 学习笔记(四)              #Region#,
iBATIS.NET 学习笔记(四)              #PostalCode#,
iBATIS.NET 学习笔记(四)              #Country#,
iBATIS.NET 学习笔记(四)              #Phone#,
iBATIS.NET 学习笔记(四)              #Fax#)
iBATIS.NET 学习笔记(四)        
</insert>
iBATIS.NET 学习笔记(四)    
</statements>
iBATIS.NET 学习笔记(四)
</sqlMap>
iBATIS.NET 学习笔记(四)
配置SqlMap.config文件
iBATIS.NET 学习笔记(四)<?xml version="1.0" encoding="utf-8"?>
iBATIS.NET 学习笔记(四)
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" 
iBATIS.NET 学习笔记(四)xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance">
iBATIS.NET 学习笔记(四)    
iBATIS.NET 学习笔记(四)    
<settings>
iBATIS.NET 学习笔记(四)        
<setting useStatementNamespaces="false"/>
iBATIS.NET 学习笔记(四)        
<setting cacheModelsEnabled="true"/>
iBATIS.NET 学习笔记(四)        
<setting validateSqlMap="false"></setting>
iBATIS.NET 学习笔记(四)
iBATIS.NET 学习笔记(四)    
</settings>
iBATIS.NET 学习笔记(四)
iBATIS.NET 学习笔记(四)    
<!-- ==== SqlClient configuration =========    -->
iBATIS.NET 学习笔记(四)    
<!-- Optional ( default ) -->
iBATIS.NET 学习笔记(四)    
<!-- Rem : If used with a Dao it will be ignored -->
iBATIS.NET 学习笔记(四)    
<database>
iBATIS.NET 学习笔记(四)        
<provider name="sqlServer1.1"/>
iBATIS.NET 学习笔记(四)        
<dataSource name="IbatisNet.Example" connectionString="data source=(local);database=Northwind;user id=sa;password=sa;"/>
iBATIS.NET 学习笔记(四)    
</database>
iBATIS.NET 学习笔记(四)    
iBATIS.NET 学习笔记(四)    
<sqlMaps>
iBATIS.NET 学习笔记(四)        
<sqlMap resource="Maps/Customers.xml"/>
iBATIS.NET 学习笔记(四)    
</sqlMaps>
iBATIS.NET 学习笔记(四)
</sqlMapConfig>
iBATIS.NET 学习笔记(四)

相关文章:

  • 2022-01-25
  • 2021-05-19
  • 2021-12-12
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-03
  • 2021-06-07
  • 2021-09-14
  • 2021-09-15
  • 2021-08-20
  • 2021-10-26
相关资源
相似解决方案