gpt4 book ai didi

sqlite - FluentNHibernate SQLite 默认配置 ProxyFactoryFactory

转载 作者:行者123 更新时间:2023-12-03 18:41:09 25 4
gpt4 key购买 nike

我想要一个简单的单元测试配置。我的理解是 sqlite fluent 配置默认为 CaSTLe,并且我有一个对 NHibernate.ByteCode.CaSTLe.dll 的引用设置,但是我收到一个错误,说没有设置 ProxyFactory 设置。

我错过了什么?

干杯,
绿柱石

=== 代码 ===

public abstract class InMemoryDatabase : IDisposable
{
private static Configuration _cfg;
private static ISessionFactory _sessionFactory;

protected InMemoryDatabase()
{
_sessionFactory = _createSessionFactory();
Session = _sessionFactory.OpenSession();
_buildSchema(Session);
}

protected ISession Session { get; set; }

#region IDisposable Members

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

#endregion

private static ISessionFactory _createSessionFactory()
{
return Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory().ShowSql())
.Mappings(M =>
M.FluentMappings.AddFromAssemblyOf<User>())
.ExposeConfiguration(Cfg => _cfg = Cfg)
.BuildSessionFactory();
}

private static void _buildSchema(ISession Session)
{
var export = new SchemaExport(_cfg);
export.Execute(true, true, false, Session.Connection, null);
}
}

==== 异常(exception) ====
TestCase 'SmackNhibTestLab.FluentMapping.Tests.UserClassMapTests.PersistenceSpec_ok'
failed: TestFixtureSetUp failed in UserClassMapTests
TestFixture failed: FluentNHibernate.Cfg.FluentConfigurationException :
An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.


----> NHibernate.Bytecode.ProxyFactoryFactoryNotConfiguredException : The ProxyFactoryFactory was not configured.
Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.
Example:
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
Example:
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()

0 passed, 1 failed, 0 skipped, took 2.55 seconds (NUnit 2.5.2).

最佳答案

您可以很容易地自己设置属性 - 请参阅下面的代码以查看一个好方法来查看一个好方法。我仍然希望这行代码已经融入 SQLite 默认配置?

private static ISessionFactory _createSessionFactory() {
var sqLiteConfiguration = Standard.InMemory().ShowSql();
sqLiteConfiguration.ProxyFactoryFactory(typeof(ProxyFactoryFactory).AssemblyQualifiedName); <== ** OK now

return Fluently.Configure()
.Database(sqLiteConfiguration)
.Mappings(M =>
M.FluentMappings.AddFromAssemblyOf<User>())
.ExposeConfiguration(Cfg => _cfg = Cfg)
.BuildSessionFactory();
}

干杯,
绿柱石

关于sqlite - FluentNHibernate SQLite 默认配置 ProxyFactoryFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1964274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com