示例#1
0
        public void find_test()
        {
            var person = new Com.Andyshi.NH3.Domain.Product()
            {
                Name = "optimistic", Category = new Category()
                {
                    Name = "cate1"
                }, Discontinued = false
            };

            using (var session = this._sessionFactory.OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    session.Save(person);

                    tx.Commit();
                }
            }

            using (var session = this._sessionFactory.OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    session.Save(person);
                }
            }
        }
示例#2
0
        public void add_new_with_category()
        {
            var category = new Com.Andyshi.NH3.Domain.Category();

            category.Name = "category1";

            var categoryrepository = new Com.Andyshi.NH3.Repositories.CategoryRepository();

            categoryrepository.Add(category);

            var product = new Com.Andyshi.NH3.Domain.Product();

            product.Name         = "product1";
            product.Category     = category;
            product.Discontinued = false;

            var productRepository = new Com.Andyshi.NH3.Repositories.ProductRepository();

            productRepository.Add(product);


            var p = productRepository.GetById(product.Id);

            p.Name = "safsfd";
            productRepository.Update(p);

            p.Name = "000000000";
            productRepository.Update(p);

            Assert.IsNotNull(p.Category);
            Assert.AreEqual(category.Name, p.Category.Name);
        }