NHibernate is a small item (seven)

xiaoxiao2021-03-06  40

Finally, the message is displayed, the message board, the message board, can't show the message, it is not a message board. The biggest difficulty here is that the data is paised, just start to remember NHibernate, see some introduced articles say it supports paging However, how is a support method but mentioned, no, can only help Google.com, and finally thank you for this article http://blog.aspcool.com/billy_zh/posts/929.aspx

NHibernate provides an interface iQuery to set query statements, parameters, etc. The implementation class for this interface is queryimpl. Like criteriaImpl, you cannot create directly outside the NHibernate program, you can only get a IQuery interface through the session. Some methods of the iQuery interface: setMaxResults: Set the maximum result number of returned, available for paging; setFirstResult: Set the position returned by the first object, available for paging; settimeout: Set the timeout value of the operation, this value will be passed to IDBCommand Object; Enumerable: Returns the enumeration object of the query; List: Returns the object collection of the query; setParameter: Set the value and type of the parameters in the query statement.

So I added it in my entity control class EntityControl.cs.

public

IList getPagentites

String

Query,

int

Start,

int

Max)

{Ilist lst; iSession s = sessionFactory.opension (); itransaction t = s.begintransaction (); lst = s.createQuery (query) .setFirstResult (START) .SETMAXRESULTS (Max) .list (); t.commit () ; S.Close (); return Lst;}

In this way, return an ilist object, which is not enough, you need to know the total record of the total data, but I don't know how to use HQL, I will not affect performance when big data, although I don't know that RecordCount can also be paised. But from the whole paging function, it is necessary to make a big discount, but also the expert.

转载请注明原文地址:https://www.9cbs.com/read-68733.html

New Post(0)