Listato7()

private void Listato7()
{
  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();
    
    for (Int32 CustId = 0; CustId < 10; ++CustId)
    {
      Customer customer = new Customer("Customer", CustId.ToString());
      for (Int32 I = 0; I < 10; ++I)
        customer.Orders.Add(new Order(DateTime.Now, I * 10.00f));
      
      session.Save(customer);
    }
    session.Flush();
  }
  
  using (ISession session = NHSessionManager.GetSession())
  {
    // IList<Customer> allcustomer = session.CreateQuery("from Customer c where c.Surname < 3").List<Customer>();
    IList<Customer>
    allcustomer = session
                  .CreateQuery("from Customer c")
                  .List<Customer>();
    foreach (Customer cust in allcustomer)
    {
      Console.WriteLine(cust.Orders.Count);
    }
  }
}