SQL Lite on NHibernate

   一直为在单元测试中测试mapping很纠结。现在用SQL Lite,不纠结了。

   首先这里SQL Lite,然后编写config文件,如下

 

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory name="NHibernate.Test">
    <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>   
    <property name="connection.connection_string">
      Data Source=a.db;Version=3;New=true
    </property>
    <property name="show_sql">true</property>
    <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>    
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,NHibernate.ByteCode.LinFu</property>        
    <mapping assembly="Ornament.MemberShip.Core" />    
  </session-factory>
</hibernate-configuration>

 

    其中,要留意一下driver_class项,如果使用我提供的SQL Lite,就必须使用 NHibernate.Driver.SQLite20Driver。如果你是下载SQL lite msi安装包,默认会把SQL Lite 放到GAC里面,那么测试项目中就需要设定<qualifyAssembly> 元素,又或者引用System.Data.SQLLite.dll后,把copy local 设定为true。否则就会出现以下异常

 

NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly..

转载于:https://www.cnblogs.com/fantasylu/archive/2010/04/27/1722049.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值