iBATIS.NET 学习笔记(二)

在VS.NET2003中使用iBATIS.NET,添加SqlMap.xsd, SqlMapConfig.xsd, providers.xsd三个文件到C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml
这样在编辑iBATIS.NET配置文件时,有提醒出现,更易用。如下所示:

SqlMap.Config 配置文件示例,(此文件放在web.config同目录)
<?xml version="1.0" encoding="utf-8"?> 
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" 
xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance" >

  
<!-- Optional -->
  
<properties resource="properties.config"/>

  
<settings>
    
<setting useStatementNamespaces="false"/>
    
<setting cacheModelsEnabled="true"/>
    
<setting validateSqlMap="false"/>
  
</settings>

  
<!-- Not required if providers.config is located in default location -->
  
<providers embedded="resources.providers.config, IBatisNet.Test"/>

  
<database>
    
<provider name="sqlServer1.1"/>
    
<dataSource name="NPetshop" 
                connectionString
="user id=${username};
                password=${password};
                data source=${datasource};
                database=${database};"
/>
  
</database>

  
<alias>
    
<typeAlias alias="Account" type="IBatisNet.Test.Domain.Account, IBatisNet.Test"/>
    
<typeAlias alias="YesNoBool"
         type
="IBatisNet.Test.Domain.YesNoBoolTypeHandlerCallback, IBatisNet.Test"/>
  
</alias>

  
<typeHandlers>
    
<typeHandler type="bool" dbType="Varchar" callback="YesNoBool"/>
  
</typeHandlers>

  
<sqlMaps>
    
<sqlMap resource="${root}Maps/Account.xml"/>
    
<sqlMap resource="${root}Maps/Category.xml"/>
    
<sqlMap resource="${root}Maps/Product.xml"/>
  
</sqlMaps> 
</sqlMapConfig>

iBATIS.NET提供了多种访问数据库的provider,如下所示:
  • sqlServer1.0 - Microsoft SQL Server 7.0/2000 provider available with .NET Framework 1.0
  • sqlServer1.1 -Microsoft SQL Server 7.0/2000 provider available with .NET Framework 1.1
  • OleDb1.1 - OleDb provider available with .NET Framework 1.1
  • Odbc1.1 - Odbc provider available with .NET Framework 1.1
  • oracle9.2 - Oracle provider V9.2.0.401
  • oracle10.1 - Oracle provider V10.1.0.301
  • oracleClient1.0 - MS Oracle provider V1.0.5 available with .NET Framework 1.1
  • ByteFx - ByteFx MySQL provider V0.7.6.15073
  • MySql - MySQL provider V1.0.4.20163
  • SQLite3 - SQLite.NET provider V0.21.1869.3794
  • Firebird1.7 - Firebird SQL .NET provider V1.7.0.33200
  • PostgreSql0.7 - Npgsql provider V0.7.0.0
  • iDb2.10 - IBM DB2 iSeries provider V10.0.0.0
posted @ 2006-07-18 22:03  Kangaroo  阅读(1806)  评论(1编辑  收藏  举报