NHibernate是否需要代理工厂?

NHibernate是否需要代理工厂?,nhibernate,nhibernate-configuration,Nhibernate,Nhibernate Configuration,我在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.DriverCon

我在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="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=SSPI;</property>
    <property name="show_sql">true</property>
  </session-factory>
</hibernate-configuration>

我已经阅读了很多教程,但还没有看到此代理工厂配置。这真的有必要吗?如果是,我该怎么做?我必须参考其他库吗?

如果您使用的是最新的NHibernate(2.1),您会注意到,对于代理生成,您所看到的所有教程可能都已经过时了

基本上,您现在可以选择如何创建动态代理,因此需要显式配置要使用的代理生成器。这方面可以找到一些例子。将引用选项的完整列表

另外,如果您想让事情简单化,只需像NHibernate的旧版本一样默认使用它。

根据,您甚至不需要再配置代理。
** NO TESTS WERE RUN (No tests found) **
TestCase 'M:IntegrationTests.RepositoryTests.ListAllPostsReturnsAListOfPost'
failed: The ProxyFactoryFactory was not configured.
Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.