Listato6()
private Boolean Listato6() { // preparo i dati per il test Int32 custId; using (ISession session = NHSessionManager.GetSession()) { session.CreateSQLQuery("delete from Orders").AddScalar("res", NHibernateUtil.Int32).UniqueResult(); session.CreateSQLQuery("delete from Customer").AddScalar("res", NHibernateUtil.Int32).UniqueResult(); Customer gianMaria = new Customer("Gian Maria", "Ricci"); for (Int32 I = 0; I < 50; ++I) gianMaria.Orders.Add(new Order(DateTime.Now, I * 10.00f)); custId = (Int32)session.Save(gianMaria); session.Flush(); } using (ISession session = NHSessionManager.GetSession()) { Customer gm = session.Get<Customer>(custId); IList<Order> page; Int32 pageNum = 0; Int32 pageSize = 10; while ((page = session .CreateFilter(gm.Orders, "") .SetFirstResult((pageNum++ * pageSize)) .SetMaxResults(pageSize) .List<Order>()).Count > 0) { foreach (Order o in page) if (o.Total > 100) { // fai qualche cosa e poi esci perchè hai trovato l'elemento return true; } } return false; } }