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

问题描述

我正在将Web项目asp.net VS2008迁移到VS2010,并将NH 2.1迁移到NH 3.2.

I'm migrating web project asp.net VS2008 to VS2010, and NH 2.1 to NH 3.2.

现在,使用NH 3.2进行分页不起作用.

Now, paging using NH 3.2 not work.

NHibernate 3.2 SetFirstresult,Setmaxresults分页问题oracle
https://groups.google.com/forum/#!topic/nhusers/1kp0hDfVol0

NHibernate 3.2 SetFirstresult, Setmaxresults paging problem oracle
https://groups.google.com/forum/#!topic/nhusers/1kp0hDfVol0

代码,与vs2008和vs2010相同,但是使用NH 3.2,分页不起作用

Code, the same for vs2008 and vs2010, but using NH 3.2, paging not works

  var response = new GetComunicacionesXFiltroResponse();

        //Sesion
        using (ISession session = NHibernateHelper.OpenSession(FlushMode.Never))
        {
            IQuery query = GetQueryForGetComunicacionesXFiltro(request, false, session);
            if (request.PagingInfo != null)
            {
                query.SetMaxResults(request.PagingInfo.RowCount);
                query.SetFirstResult((request.PagingInfo.PageNumber - 1) * request.PagingInfo.RowCount);
            }
            response.Comunicaciones = ComunicacionMapper.Map(query.List<Comunicacion>());

        }

配置NH 3.2

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
  <reflection-optimizer use="false"/>
  <session-factory>
    <property name="connection.connection_string_name">XXX.ConnectionStrings.Oracle.XXX</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
    <property name="connection.isolation">ReadCommitted</property>
    <property name="dialect">NHibernate.Dialect.Oracle9iDialect</property>

    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
    <property name="show_sql">false</property>
    <property name="use_proxy_validator">false</property>
    <!--DEPRECATED<property name="use_outer_join">true</property>-->
    <mapping assembly="XXX.MonitorizacionB2b.DomainModel"/>
  </session-factory>
</hibernate-configuration>

对此有何建议?

推荐答案

伊朗遇到了同样的问题.分页工作在3.3中.下载源代码并自己进行编译,或者从

Iran into the same problem. Paging is working in 3.3. Download the source and compile it yourself or pull the nightly builds from

http://teamcity.codebetter.com/viewType.html? buildTypeId = bt7& tab = buildTypeStatusDiv

这篇关于NHibernate 3.2和分页Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:57