コード例 #1
0
ファイル: Fixture.cs プロジェクト: osoykan/nhibernate-core
        protected override void OnSetUp()
        {
            using (var session = OpenSession())
            using (var transaction = session.BeginTransaction())
            {
                var product = new Product("T001", "T-Shirt");
                var product2 = new Product("U001", "Underwear");
                var variant = new ProductVariant("RED", "R001", product);
                var variant2 = new ProductVariant("YELLOW", "Y001", product2);

                product.AddVariant(variant);
                product2.AddVariant(variant2);
                session.Save(product);
                session.Save(product2);

                var user = new MembershipUser(25, "*****@*****.**", "OguzhanSoykan");
                var emailHistory = new MembershipUserEmailHistory(DateTime.Now, "*****@*****.**", user);
                var address = new MembershipUserAddress("221b baker street", user);
                var phone = new MembershipUserPhone("55544433322", user);
                var segment = new MembershipUserSegment("Rich User", DateTime.Now, user);
                user.AddAddress(address).AddEmailHistory(emailHistory).AddPhone(phone).AddSegment(segment);
                session.Save(user);

                var basket = new MembershipUserBasket(Guid.NewGuid(), DateTime.Now, user);
                basket.AddProduct(new MembershipUserBasketProduct(basket, DateTime.Now, product));
                basket.AddProduct(new MembershipUserBasketProduct(basket, DateTime.Now, product2));

                var orderline = new MembershipOrderLine(product, 8);
                var orderline2 = new MembershipOrderLine(product2, 2);
                var order = new MembershipOrder(user, basket).AddOrderLine(orderline).AddOrderLine(orderline2);

                session.Save(order);

                session.Flush();
                transaction.Commit();
            }
        }
コード例 #2
0
 public virtual MembershipUser AddEmailHistory(MembershipUserEmailHistory emailHistory)
 {
     this.EmailHistories.Add(emailHistory);
     return this;
 }