Пример #1
0
		public virtual void AddOffspring(Animal offSpring)
		{
			if (offspring == null)
			{
				offspring = new HashedSet<Animal>();
			}

			offspring.Add(offSpring);
		}
			public void Prepare()
			{
				ISession s = tc.OpenNewSession();
				ITransaction txn = s.BeginTransaction();

				Polliwog = new Animal {BodyWeight = 12, Description = "Polliwog"};

				Catepillar = new Animal {BodyWeight = 10, Description = "Catepillar"};

				Frog = new Animal {BodyWeight = 34, Description = "Frog"};

				Polliwog.Father = Frog;
				Frog.AddOffspring(Polliwog);

				Butterfly = new Animal {BodyWeight = 9, Description = "Butterfly"};

				Catepillar.Mother = Butterfly;
				Butterfly.AddOffspring(Catepillar);

				s.Save(Frog);
				s.Save(Polliwog);
				s.Save(Butterfly);
				s.Save(Catepillar);

				var dog = new Dog {BodyWeight = 200, Description = "dog"};
				s.Save(dog);

				var cat = new Cat {BodyWeight = 100, Description = "cat"};
				s.Save(cat);

				Zoo = new Zoo {Name = "Zoo"};
				var add = new Address {City = "MEL", Country = "AU", Street = "Main st", PostalCode = "3000"};
				Zoo.Address = add;

				PettingZoo = new PettingZoo {Name = "Petting Zoo"};
				var addr = new Address {City = "Sydney", Country = "AU", Street = "High st", PostalCode = "2000"};
				PettingZoo.Address = addr;

				s.Save(Zoo);
				s.Save(PettingZoo);

				var joiner = new Joiner {JoinedName = "joined-name", Name = "name"};
				s.Save(joiner);

				var car = new Car {Vin = "123c", Owner = "Kirsten"};
				s.Save(car);

				var truck = new Truck {Vin = "123t", Owner = "Steve"};
				s.Save(truck);

				var suv = new SUV {Vin = "123s", Owner = "Joe"};
				s.Save(suv);

				var pickup = new Pickup {Vin = "123p", Owner = "Cecelia"};
				s.Save(pickup);

				var b = new BooleanLiteralEntity();
				s.Save(b);

				txn.Commit();
				s.Close();
			}
            public void Prepare()
            {
                ISession     s   = tc.OpenNewSession();
                ITransaction txn = s.BeginTransaction();

                Polliwog = new Animal {
                    BodyWeight = 12, Description = "Polliwog"
                };

                Catepillar = new Animal {
                    BodyWeight = 10, Description = "Catepillar"
                };

                Frog = new Animal {
                    BodyWeight = 34, Description = "Frog"
                };

                Polliwog.Father = Frog;
                Frog.AddOffspring(Polliwog);

                Butterfly = new Animal {
                    BodyWeight = 9, Description = "Butterfly"
                };

                Catepillar.Mother = Butterfly;
                Butterfly.AddOffspring(Catepillar);

                s.Save(Frog);
                s.Save(Polliwog);
                s.Save(Butterfly);
                s.Save(Catepillar);

                var dog = new Dog {
                    BodyWeight = 200, Description = "dog"
                };

                s.Save(dog);

                var cat = new Cat {
                    BodyWeight = 100, Description = "cat"
                };

                s.Save(cat);

                Zoo = new Zoo {
                    Name = "Zoo"
                };
                var add = new Address {
                    City = "MEL", Country = "AU", Street = "Main st", PostalCode = "3000"
                };

                Zoo.Address = add;

                PettingZoo = new PettingZoo {
                    Name = "Petting Zoo"
                };
                var addr = new Address {
                    City = "Sydney", Country = "AU", Street = "High st", PostalCode = "2000"
                };

                PettingZoo.Address = addr;

                s.Save(Zoo);
                s.Save(PettingZoo);

                var joiner = new Joiner {
                    JoinedName = "joined-name", Name = "name"
                };

                s.Save(joiner);

                var car = new Car {
                    Vin = "123c", Owner = "Kirsten"
                };

                s.Save(car);

                var truck = new Truck {
                    Vin = "123t", Owner = "Steve"
                };

                s.Save(truck);

                var suv = new SUV {
                    Vin = "123s", Owner = "Joe"
                };

                s.Save(suv);

                var pickup = new Pickup {
                    Vin = "123p", Owner = "Cecelia"
                };

                s.Save(pickup);

                var b = new BooleanLiteralEntity();

                s.Save(b);

                txn.Commit();
                s.Close();
            }