SQLite NHibernate配置.Net 4.0和vs 2010

前端之家收集整理的这篇文章主要介绍了SQLite NHibernate配置.Net 4.0和vs 2010前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在用我认为现在知道的关于获得此配置的内容更新这篇文章;但是,还有更多要知道,因为我仍然有一个问题是一个关键领域.

我使用sqlite进行单元测试,现在可以正常工作,使用下面的配置步骤.当我想要使用比内存中测试数据更多的数据的UI测试运行但没有sqlServer的开销时,我也使用它 – 此配置失败,具有以下内容

{"Could not create the driver from NHibernate.Driver.sqlite20Driver,NHibernate,Version=2.1.0.4000,Culture=neutral,PublicKeyToken=aa95f207798dfdb4."}

这里有关于工作的配置的更新信息:

1)哪个sqlite DLL?有一些不好的链接看起来很有帮助但是在它们中存在构建错误.截至此日期唯一的好下载是here at Source Forge. v1.066,今天发布,2010年4月18日.

2)您必须使用GAC吗?不,正如毛里西奥回答的那样.

3)x64版本 – 由Mauricio回答.

4)NHib驱动程序 – sqlite20Driver,由Mauricio回答

5)FNH是潜在的冲突 – 不,正如Mauricio所回答的那样

干杯,
Berryl

== ADD’L DEBUG INFO ===

当异常被击中并且我调用sqlite20Drive程序集时,我得到以下内容,这表明驱动程序应该可用.我想知道,因为配置代码在不同的程序集中.

– 装配时出错—-

?typeof(sqlite20Driver).Assembly
{NHibernate,PublicKeyToken=aa95f207798dfdb4}
[System.Reflection.RuntimeAssembly]: {NHibernate,PublicKeyToken=aa95f207798dfdb4}
CodeBase: "file:///C:/Users/Lord & Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.WpfPresentation/bin/Debug/NHibernate.DLL"
EntryPoint: null
EscapedCodeBase: "file:///C:/Users/Lord%20%26%20Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.WpfPresentation/bin/Debug/NHibernate.DLL"
Evidence: {System.Security.Policy.Evidence}
FullName: "NHibernate,PublicKeyToken=aa95f207798dfdb4"
GlobalAssemblyCache: false
HostContext: 0
ImageRuntimeVersion: "v2.0.50727"
IsDynamic: false
IsFullyTrusted: true
Location: "C:\\Users\\Lord & Master\\Documents\\Projects\\Smack\\trunk\\src\\ConstructionAdmin.WpfPresentation\\bin\\Debug\\NHibernate.dll"
ManifestModule: {NHibernate.dll}
PermissionSet: {<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
}
ReflectionOnly: false
SecurityRuleSet: Level1

—单元测试时的装配(NO ERROR)

{NHibernate,PublicKeyToken=aa95f207798dfdb4}
CodeBase: "file:///C:/Users/Lord & Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.Tests/bin/Debug/NHibernate.DLL"
EntryPoint: null
EscapedCodeBase: "file:///C:/Users/Lord%20%26%20Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.Tests/bin/Debug/NHibernate.DLL"
Evidence: {System.Security.Policy.Evidence}
FullName: "NHibernate,PublicKeyToken=aa95f207798dfdb4"
GlobalAssemblyCache: false
HostContext: 0
ImageRuntimeVersion: "v2.0.50727"
IsDynamic: false
IsFullyTrusted: true
Location: "C:\\Users\\Lord & Master\\Documents\\Projects\\Smack\\trunk\\src\\ConstructionAdmin.Tests\\bin\\Debug\\NHibernate.dll"
ManifestModule: {NHibernate.dll}
PermissionSet: {<PermissionSet class="System.Security.PermissionSet"

版本= “1”
无限制= “真”/>
}
ReflectionOnly:false
SecurityRuleSet:Level1

以下是sqlite会话的引导程序:

/// <summary>sqlite-NHibernate bootstrapper for general use.</summary>
public class sqliteBoot : IDisposable
{
    public readonly ISessionFactory SessionFactory;
    private readonly ISession _session;
    private static Configuration _config;
    private static string _persistenceModelGeneratorName;

    public sqliteBoot(IAutoPersistenceModelGenerator persistenceModelGenerator) {
        if (_isSessionFactoryBuildrequired(persistenceModelGenerator)) {
            _config = new Configuration()
                .SetProperty(ENV.ReleaseConnections,"on_close")
                .SetProperty(ENV.Dialect,typeof (sqliteDialect).AssemblyQualifiedName)
                .SetProperty(ENV.ConnectionDriver,typeof (sqlite20Driver).AssemblyQualifiedName)
                .SetProperty(ENV.ConnectionString,"data source=:memory:")
                .SetProperty(ENV.ProxyFactoryFactoryClass,typeof (ProxyFactoryFactory).AssemblyQualifiedName)
                .SetProperty(ENV.CurrentSessionContextClass,typeof (ThreadStaticSessionContext).AssemblyQualifiedName);

            _persistenceModelGeneratorName = persistenceModelGenerator.Name;
            var persistenceModel = persistenceModelGenerator.Generate();
            var fluentCfg = Fluently.Configure(_config).Mappings(m => m.AutoMappings.Add(persistenceModel));
            SessionFactory = fluentCfg.BuildSessionFactory();
            Check.Require(SessionFactory.GetAllClassMetadata().Count > 0,"No mapped classes - check your AutoPersistenceModel!");

        }

        _session = SessionFactory.OpenSession();
        CurrentSessionContext.Bind(_session);

        new SchemaExport(_config).Execute(true,true,false,_session.Connection,Console.Out);
    }

    private bool _isSessionFactoryBuildrequired(IAutoPersistenceModelGenerator persistenceModelGenerator)
    {
        return
            _config == null
            || SessionFactory == null
            || !persistenceModelGenerator.Name.Equals(_persistenceModelGeneratorName);
    }

    public void Dispose()
    {
        _session.Dispose();
    }
}

}

>当然.如果配置 mixed mode loading,也可以使用以前的版本.
>无需加入GAC.您可以使用gacutil从GAC中删除程序集.
>使用x64 DLL以Windows x86为目标Windows x64和x86
>请发布完整的异常堆栈跟踪.此外,如果您使用3.5组件使用 mixed mode loading. > FNH没有提到sqlite.

猜你在找的Sqlite相关文章