Mybatis.Net 整合 ODP.NET Managed

初步接触MyBatis.Net的朋友,请先移步 MyBatis.Net 学习手记 
1. 项目中先添加Oracle.ManagedDataAccess.dll程序集引用

2. MyBatis.Net 中Providers.config文件修改

 1 <provider
 2     name="ODP.NET Managed"
 3     description="Oracle, ODP.NET Managed 4.121.1.0"
 4     enabled="true"
 5     assemblyName="Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"
 6     connectionClass="Oracle.ManagedDataAccess.Client.OracleConnection"
 7     commandClass="Oracle.ManagedDataAccess.Client.OracleCommand"
 8     parameterClass="Oracle.ManagedDataAccess.Client.OracleParameter"
 9     parameterDbTypeClass="Oracle.ManagedDataAccess.Client.OracleDbType"
10     parameterDbTypeProperty="OracleDbType"
11     dataAdapterClass="Oracle.ManagedDataAccess.Client.OracleDataAdapter"
12     commandBuilderClass="Oracle.ManagedDataAccess.Client.OracleCommandBuilder"
13     usePositionalParameters="true"
14     useParameterPrefixInSql="true"
15     useParameterPrefixInParameter="true"
16     parameterPrefix=":"
17     useDeriveParameters="false"
18     allowMARS="false"  
19 />

tips:

a) assemblyName类型不知道如何填写的,可通过类似 Assembly.LoadFile(@"D:\soft\ODP.NET_Managed121010\odp.net\managed\common\Oracle.ManagedDataAccess.dll").FullName获得

b)name,description 这二处可随便填写

3.MyBatis.Net中SqlMap.config的相关节点修改

1 <!--db provider类型及连接串-->
2 <database>
3     <provider name="ODP.NET Managed" /> <!--这里要与Providers.config中的nama保持一致-->
4     <dataSource name="oracle" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=***.***.***.***)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=***)));Persist Security Info=True;User ID=***;Password=***;" />
5 </database>

 

posted @ 2013-11-01 10:40  菩提树下的杨过  阅读(3588)  评论(1编辑  收藏  举报