本文介绍了转换成流利的NHibernate sessionmanager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变我的应用程序使用流利的NHibernate。我创建了我的Fluent映射文件,现在已经转移到配置我的会话管理器。目前我使用下面的代码:
$ b $ pre $ private $ ISessionFactory GetSessionFactory

return(new Configuration 。())配置BuildSessionFactory()();
}

与我的hibernate.cfg.xml一起 -

 <?xml version =1.0encoding =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>

有谁知道我可以怎样把这个转移到流利?我遇到的问题是配置的数据库部分。



感谢您的任何想法。

解决方案

对于,您需要下载最新的流利nhibernate二进制文件(#680为我工作):

$ p $私有ISessionFactory CreateSessionFactory(
{
返回流利.Configure()
.Database(
IfxOdbcConfiguration
.Informix1000 $ b $ .ConnectionString(Provider = Ifxoledbc.2; Password = mypass; Persist Security Info = True;用户ID = myid;数据源= mysource)
.Driver< OleDbDriver>()
.Dialect< InformixDialect1000>()
.ProxyFactoryFactory< ProxyFactoryFactory>()

.Mappings(
m => m
.FluentMappings
.AddFromAssemblyOf< SomePersistentType>()

.BuildSessionFactory();
}


I am changing my application to use Fluent NHibernate. I have created my Fluent mapping files and have now moved onto configuring my Session Manager. Currently, I use the following code -

private ISessionFactory GetSessionFactory()
{
     return (new Configuration()).Configure().BuildSessionFactory();
}

Along with my 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>

Does anyone know how I could transfer this to Fluent? The problem I have having is with the Database portion of the configuration.

Thanks for any thoughts.

For informix support you will need to download the latest fluent nhibernate binary (#680 worked for me):

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();
}

这篇关于转换成流利的NHibernate sessionmanager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:23