Ejemplo n.º 1
0
		protected override void OnSetUp()
		{
			base.OnSetUp();
			using (ISession session = this.OpenSession())
			{
				var cat1 = new Cat()
				{
					Id = 1,
					Name = "Cat 1",
					Born = DateTime.Now,
				};
				session.Save(cat1);

				var cat2 = new Cat()
				{
					Id = 2,
					Name = "Cat 2",
					Born = DateTime.Now,
				};
				session.Save(cat2);

				var dog1 = new Dog()
				{
					Id = 1,
					Name = "Dog 1",
					Walks = 11,
				};
				session.Save(dog1);

				var toy1 = new Toy()
				{
					Id = 1,
					Name = "Toy 1",
				};
				toy1.Animals.Add(cat1);
				toy1.Animals.Add(cat2);
				toy1.Animals.Add(dog1);
				session.Save(toy1);

				session.Flush();
			}
		}
Ejemplo n.º 2
0
        protected override void OnSetUp()
        {
            base.OnSetUp();
            using (ISession session = this.OpenSession())
            {
                var cat1 = new Cat()
                {
                    Id   = 1,
                    Name = "Cat 1",
                    Born = DateTime.Now,
                };
                session.Save(cat1);

                var cat2 = new Cat()
                {
                    Id   = 2,
                    Name = "Cat 2",
                    Born = DateTime.Now,
                };
                session.Save(cat2);

                var dog1 = new Dog()
                {
                    Id    = 1,
                    Name  = "Dog 1",
                    Walks = 11,
                };
                session.Save(dog1);

                var toy1 = new Toy()
                {
                    Id   = 1,
                    Name = "Toy 1",
                };
                toy1.Animals.Add(cat1);
                toy1.Animals.Add(cat2);
                toy1.Animals.Add(dog1);
                session.Save(toy1);

                session.Flush();
            }
        }