我正在更改我的应用程序以使用Fluent NHibernate。我已经创建了我的Fluent映射文件,现在已经开始配置我的会话管理器了。目前,我使用以下代码 -
private ISessionFactory GetSessionFactory()
{
return (new Configuration()).Configure().BuildSessionFactory();
}
与我的hibernate.cfg.xml -
一起<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.InformixDialect1000</property>
<property name="connection.driver_class">NHibernate.Driver.OleDbDriver</property>
<property name="connection.connection_string">Provider=Ifxoledbc.2;Password=mypass;Persist Security Info=True;User ID=myid;Data Source=mysource</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<property name="show_sql">false</property>
<mapping assembly="DataTransfer" />
</session-factory>
</hibernate-configuration>
有谁知道如何将此转移到Fluent?我遇到的问题是配置的数据库部分。
感谢您的任何想法。
答案 0 :(得分:3)
对于informix support,您需要下载latest fluent nhibernate binary(#680为我工作):
private ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.Database(
IfxOdbcConfiguration
.Informix1000
.ConnectionString("Provider=Ifxoledbc.2;Password=mypass;Persist Security Info=True;User ID=myid;Data Source=mysource")
.Driver<OleDbDriver>()
.Dialect<InformixDialect1000>()
.ProxyFactoryFactory<ProxyFactoryFactory>()
)
.Mappings(
m => m
.FluentMappings
.AddFromAssemblyOf<SomePersistentType>()
)
.BuildSessionFactory();
}
答案 1 :(得分:0)
jon - 这是我最终使用的 -
return Fluently.Configure()
.Database(
IfxOdbcConfiguration
.Informix1000
.ConnectionString("Provider=Ifxoledbc.2;Password=password;Persist Security Info=True;User ID=username;Data Source=database@server")
.Dialect<InformixDialect1000>()
.ProxyFactoryFactory<ProxyFactoryFactory>()
.Driver<OleDbDriver>()
.ShowSql()
)
.Mappings(m => m.AutoMappings.Add(persistenceModel))
.BuildSessionFactory();
我不确定你到底在找什么,所以让我知道这是否有效。 感谢