I read and implemented Trying to using Nhibernate with Mono & SQLite - can't find System.Data.SQLite However, as the last comment there states this seems not to work with NHibernate 3.1
The error is
HibernateException: The IDbCommand and IDbConnection implementation in the assembly Mono.Data.Sqlite could not be found. Ensure that the assembly Mono.Data.Sqlite is [...reachable...]
I have Mono.Data.Sqlite in the GAC.
I have tried both specifying "Mono.Data.Sqlite" as well as typeof(Mono.Data.Sqlite.SqliteConnection).Assembly.FullName
as the name of the assembly
Has anyone any Ideas how to get this working?
There is a problem in the answer of Trying to using Nhibernate with Mono & SQLite - can't find System.Data.SQLite . For the given constructor (3 parameters) to work the assembly in question (Mono.Data.Sqlite) needs to be loaded first.
This works if the 4-parameter base contructor is used like this:
public class MonoSQLiteDriver : NHibernate.Driver.ReflectionBasedDriver
{
public MonoSQLiteDriver()
: base(
"Mono.Data.Sqlite",
"Mono.Data.Sqlite",
"Mono.Data.Sqlite.SqliteConnection",
"Mono.Data.Sqlite.SqliteCommand")
{
}
public override bool UseNamedPrefixInParameter {
get {
return true;
}
}
public override bool UseNamedPrefixInSql {
get {
return true;
}
}
public override string NamedPrefix {
get {
return "@";
}
}
public override bool SupportsMultipleOpenReaders {
get {
return false;
}
}
}
(Still, credit goes to http://intellect.dk/post/Why-I-love-frameworks-with-lots-of-extension-points.aspx for the original idea - thanks.)
And if you use FluentNHibernate, then you'll also need:
public class MonoSQLiteConfiguration : PersistenceConfiguration<MonoSQLiteConfiguration>
{
public static MonoSQLiteConfiguration Standard
{
get { return new MonoSQLiteConfiguration(); }
}
public MonoSQLiteConfiguration()
{
Driver<MonoSQLiteDriver>();
Dialect<SQLiteDialect>();
Raw("query.substitutions", "true=1;false=0");
}
public MonoSQLiteConfiguration InMemory()
{
Raw("connection.release_mode", "on_close");
return ConnectionString(c => c
.Is("Data Source=:memory:;Version=3;New=True;"));
}
public MonoSQLiteConfiguration UsingFile(string fileName)
{
return ConnectionString(c => c
.Is(string.Format("Data Source={0};Version=3;New=True;", fileName)));
}
public MonoSQLiteConfiguration UsingFileWithPassword(string fileName, string password)
{
return ConnectionString(c => c
.Is(string.Format("Data Source={0};Version=3;New=True;Password={1};", fileName, password)));
}
}
I have not encountered any problems so far...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With