Listato2()
private static void Listato2() { // preparo i dati per il test 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"); Order order1 = new Order(DateTime.Now, 10.00f); Order order2 = new Order(DateTime.Now, 20.00f); gianMaria.Orders.Add(order1); gianMaria.Orders.Add(order2); session.Save(gianMaria); session.Flush(); } // Cancello un ordine using (ISession session = NHSessionManager.GetSession()) { Customer gm = session.CreateQuery("select c from Customer c where c.Name = 'Gian Maria'").UniqueResult(); Order o = gm.Orders[0]; gm.Orders.Remove(o); session.Flush(); } }