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
總結
以上是生活随笔為你收集整理的SQL Lite on NHibernate的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 解决bad SQL grammar []
- 下一篇: YAML文件解析