当前位置:编程学习 > C#/ASP.NET >>

IBatisNet :有没有熟悉最新版本的高手啊?

有没有谁用过将数据源配置独立出来的?帮我解答点问题!


我的配置文件dao.config
<?xml version="1.0" encoding="utf-8"?>


<daoConfig
xmlns="http://ibatis.apache.org/dataAccess"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <providers resource="providers.config"/>

  <context id="AccessMapDao" default="true">
  <database>
  <provider name="OleDb2.0" />
  <dataSource name="Access" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\NEWS\NEWS\App_Data\demo.mdb;" />
  </database>
  <daoSessionHandler id="SqlMap">
  <property name="resource" value="sqlMap.config"/>
  </daoSessionHandler>
  <daoFactory>
  <dao
  interface="YTO.Intranet.News.IDAL.IMajorNewsDao, NEWS"
  implementation="YTO.Intranet.News.DAL.MajorNewsDao, NEWS"/>
  </daoFactory>

  </context>
</daoConfig>

我的配置文件sqlMap.comfig
<?xml version="1.0" encoding="utf-8"?>

  <sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper"  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <properties resource="providers.config"/>
  <properties embedded="dao.config, NEWS"/>
  <settings>
  <setting useStatementNamespaces="true"/>
  </settings>
  <sqlMaps>
  <sqlMap resource="NEWS/sqlMaps/MajorNews.config"/>
  </sqlMaps>
</sqlMapConfig>



我用了一个BLL层来作为对数据库的操作
  public class MajorNewsBiz
  {
  private IDaoManager daoManager;
  private IMajorNewsDao majorNewsDao;
  public MajorNewsBiz()
  {
  daoManager = ServiceConfig.GetInstance().DaoManager;
  majorNewsDao = daoManager.GetDao(typeof(IMajorNewsDao)) as IMajorNewsDao;
  }
  }
直接运行的话报configurationException错:
- The error occurred while configure DaoSessionHandler.
- The error occurred in <property name="resource" value="sqlMap.config" xmlns="http://ibatis.apache.org/dataAccess" />.   
- Check the IBatisNet.DataAccess.DaoSessionHandlers.SqlMapDaoSessionHandler.


然后我把dao.config中的
  <daoSessionHandler id="SqlMap">
  <property name="resource" value="sqlMap.config"/>
  </daoSessionHandler>
给注释掉了之后运行!

报DataAccessException错误:
 DaoProxy : unable to intercept method name 'FindAllMajorNews', cause : 无法将类型为“IBatisNet.DataAccess.DaoSessionHandlers.SimpleDaoSession”的对象强制转换为类型“IBatisNet.DataAccess.DaoSessionHandlers.SqlMapDaoSession”。

这个到底是什么原因啊!
我下载了价格Demo看了下,一样的配置啊,没什么问题啊!
--------------------编程问答-------------------- --------------------编程问答-------------------- http://blog.csdn.net/kolacowboy/archive/2007/09/01/1768593.aspx --------------------编程问答-------------------- IBatisNet配置太麻烦,推荐从 IBatisNet 继承过来的“PDF.NET数据开发框架”(搜索一下就知道了),几乎是0配置,能够快速上手,也能够做大型项目。
--------------------编程问答-------------------- 我也想用SHS啊,关键是公司的前期开发就用的这个框架,我后面要改就要全部重做,没精力啊,没人手啊
!只能赶鸭子上架学习C#了啊! --------------------编程问答-------------------- 2楼给的例子一点用处都没有啊,关键我是要解决我的问题啊,你给个简单的DEMO有什么用啊,我就是按这样的格式来配置的! --------------------编程问答--------------------
引用楼主 min420625 的回复:
有没有谁用过将数据源配置独立出来的?帮我解答点问题!


我的配置文件dao.config
<?xml version="1.0" encoding="utf-8"?>


<daoConfig
xmlns="http://ibatis.apache.org/dataAccess"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-insta……



关键是怎么显式转换啊?能说清楚点吗?
在哪儿进行转换啊!
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,