尝试使用NHibernate与单声道功放&; SQLite的 - 无法找到System.Data.SQLite [英] Trying to using Nhibernate with Mono & SQLite - can't find System.Data.SQLite

查看:175
本文介绍了尝试使用NHibernate与单声道功放&; SQLite的 - 无法找到System.Data.SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写单(C#)一个简单的应用程序使用NHibernate的与MySQL的 - 我现在想把它移植到SQLite的

I wrote a simple app in mono (C#) that uses NHibernate with MYSQL - and I now want to port it to SQLite.

我的希望是(被)。我可以简单地改变hibernate.cfg.xml文件并将其指向不同的数据库。这是我修改的hibernate.cfg.xml:

My hope is (was) that I could simply change hibernate.cfg.xml and point it to a different database. Here is my modified hibernate.cfg.xml:

    <?xml version="1.0" encoding="utf-8" ?>

    <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=nhibernate_test.db;Version=3
            </property>
            <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
            <property name="query.substitutions">true=1;false=0</property>
            <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
        </session-factory>

</hibernate-configuration> 

的问题是,我得到一个错误,它无法找到系统的影响。 Data.SQLite。因为这并不让我感到吃惊,我的理解是,在单,我们应该使用Mono.Data.SQLite。

The problem is that I'm getting an error to the effect that it can't find System.Data.SQLite. This doesn't surprise me since, as I understand it, in mono we should be using Mono.Data.SQLite.

麻烦的是(假设我理解。问题正确的),我不知道如何告诉NHibernate的使用Mono.Data.SQLite代替System.Data.SQLite

The trouble is (assuming I'm understanding the problem correctly) I don't know how to tell NHibernate to use Mono.Data.SQLite instead of System.Data.SQLite.

这是被所有在Linux上做的 - 如果让任何区别。

This is all being done on Linux - if that makes any difference.

没有人有任何想法如何进行呢?

Does anyone have any ideas how to proceed?

推荐答案

您需要让NHibernate的知道Mono.Data.SQLite组装。这种添加到配置:

You need to make nHibernate aware of the Mono.Data.SQLite assembly. Add this to the configuration:

<add key="connection.driver_class" value="Name.Space.MonoSqliteDriver, AssemblyName" />

和您还需要一个简单的 MonoSQLiteDriver

And you also need a simple MonoSQLiteDriver class:

public class MonoSqliteDriver : NHibernate.Driver.ReflectionBasedDriver  
{  
    public MonoSqliteDriver() :   
        base("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;  
        }  
    }  
}  



(从<一取码HREF =http://intellect.dk/post/Why-I-love-frameworks-with-lots-of-extension-points.aspx> http://intellect.dk/post/Why-I-love-框架与 - 很多-的扩展-points.aspx )

这篇关于尝试使用NHibernate与单声道功放&; SQLite的 - 无法找到System.Data.SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆