public void AddPaymentMethodWithNhibernate()
        {
            ISession session = ServiceLocator.Factory.OpenSession();

            var method = new Domain.CreditCardPaymentMethod { RegistrationDate = DateTime.Now, Status = 2, CardHolderName = "Roman Jendrusz", CardNumber = "1234", CardType = "Visa" };
            var method2 = new Domain.DirectDebitPaymentMethod
                              {
                                  RegistrationDate = DateTime.Now,
                                  Status = 1,
                                  BankAccountNumber = "123123",
                                  HolderName = "sciemniacz"
                              };

            var customer = new Domain.Customer{Name = "Roman"};
            method.AssignedTo =  customer;
            method2.AssignedTo = customer;
            customer.UsedPaymentMethod = method2;
            var customer2 = new Domain.Customer { Name = "Marcin" };
            customer2.UsedPaymentMethod = method2;
            using(ITransaction transaction = session.BeginTransaction())
            {
                session.Save(customer);
                session.Save(method);
                session.Save(method2);
                transaction.Commit();
            }
            //IList<Domain.PaymentMethod> methods = session.CreateQuery("from PaymentMethod pm where pm.AssignedTo = :customer")
            //    .SetParameter("customer", customer)
            //    .List<Domain.PaymentMethod>();
            session = ServiceLocator.Factory.OpenSession();
            IList<Domain.PaymentMethod> methods =
                session.Linq<Domain.PaymentMethod>().Where(pm => pm.AssignedTo == customer).ToList();
            foreach (var paymentMethod in methods)
            {
                Console.WriteLine(paymentMethod.GetType().ToString());
            }
        }
 public void ShouldRetrieveTheAssociatedObjectThatIsADerivedClass()
 {
     using (var scope = new TransactionScope())
     {
         ISession session = ServiceLocator.Factory.OpenSession();
         string customerName = "Test Customer";
         using (ITransaction transaction = session.BeginTransaction())
         {
             var customer = new Domain.Customer {Name = customerName};
             var paymentMethod = new Domain.CreditCardPaymentMethod
                                     {
                                         AssignedTo = customer,
                                         CardHolderName = "Joseph",
                                         CardNumber = "AAABBB!@#12",
                                         CardType = "Visa",
                                         RegistrationDate = new DateTime(2008, 10, 10),
                                         Status = 1
                                     };
             session.Save(customer);
             session.Save(paymentMethod);
             customer.UsedPaymentMethod = paymentMethod;
             transaction.Commit();
         }
         session = ServiceLocator.Factory.OpenSession();
         var previouslyAddedCustomer = session.Linq<Domain.Customer>().Where(x => x.Name == customerName).First();
         Assert.That(previouslyAddedCustomer.UsedPaymentMethod, Is.TypeOf<Domain.CreditCardPaymentMethod>());
     }
 }