I have the following nhibernate cfg file:
<property name="connection.provider">NHibernate.Connection.DriverConnectionPr开发者_如何学JAVAovider</property>
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<property name="connection.connection_string">Data Source=dbFile.db;Version=3</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
However this creates and references dbFile.db in the bin/Debug folder. I was wondering if there is any way to refernce another folder i.e. something like .../app/database/dbFile.db?
Thanks in advance
You can set the connection string property from c# code. You have to do this before you call the Configure() method.
var configuration = new Configuration();
config.SetProperty(NHibernate.Cfg.Environment.ConnectionString, myCustomDbPath);
configuration.Configure();
Hope that helps.
Maybe you can use DataDirectory-Property to start from the Exe-Path:
Data Source=|DataDirectory|../app/database/dbFile.db;Version=3
or
Data Source=jdbc:sqlite:../app/database/path.db;Version=3
Edit: After some googling i found out that this probably won't work. if not i would go with striders solution setting the property at runtime.
精彩评论