由于AR对数据的连接就直接是NH,所以其实就是NH的Access连接问题。
因为空间上用的Access数据库,所以选择了NHibernate.JetDrive驱动
(可以到www.hibernate.org下载,包含在NHibernateContrib的bin中)
NH直接地址http://www.hibernate.org/343.html
官方对于Databases supported by NHibernate(http://www.hibernate.org/361.html)
Access操作时仍然存在一些Bug官方原文
Issue
There are still few problems with join syntax in queries that use more than one join. This driver passes 93% of NHibernate tests (there are 23 failing tests).
The most complete topic about these issues is here: Using NHibernate with Microsoft Access 2003 / Jet 4.0. JIRA issues NH-124 and NH-437 have some information on problems with implementing Microsoft Access dialect. You can also try searching NHibernate forum for "access jet" (require all words).
实际使用:
引用 NHibernate.JetDriver.dll
配置文件这么写
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler,System,Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<nhibernate>
<add key="hibernate.show_sql" value="true" />
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="hibernate.dialect" value="NHibernate.JetDriver.JetDialect,NHibernate.JetDriver" />
<add key="hibernate.connection.driver_class" value="NHibernate.JetDriver.JetDriver,NHibernate.JetDriver" />
<add key="hibernate.connection.connection_string" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb" />
</nhibernate>
特别注意加色部分,如果没有写对经常出错。