Ejemplo n.º 1
0
            public void Prepare()
            {
                ISession     session = tc.OpenNewSession();
                ITransaction txn     = session.BeginTransaction();

                var mother = new Human {
                    BodyWeight = 10, Description = "mother"
                };

                var father = new Human {
                    BodyWeight = 15, Description = "father"
                };

                var child1 = new Human {
                    BodyWeight = 5, Description = "child1"
                };

                var child2 = new Human {
                    BodyWeight = 6, Description = "child2"
                };

                var friend = new Human {
                    BodyWeight = 20, Description = "friend"
                };

                child1.Mother = mother;
                child1.Father = father;
                mother.AddOffspring(child1);
                father.AddOffspring(child1);

                child2.Mother = mother;
                child2.Father = father;
                mother.AddOffspring(child2);
                father.AddOffspring(child2);

                father.Friends = new[] { friend };

                session.Save(mother);
                session.Save(father);
                session.Save(child1);
                session.Save(child2);
                session.Save(friend);

                txn.Commit();
                session.Close();
            }
Ejemplo n.º 2
0
            public async Task PrepareAsync(CancellationToken cancellationToken = default(CancellationToken))
            {
                ISession     session = tc.OpenNewSession();
                ITransaction txn     = session.BeginTransaction();

                var mother = new Human {
                    BodyWeight = 10, Description = "mother"
                };

                var father = new Human {
                    BodyWeight = 15, Description = "father"
                };

                var child1 = new Human {
                    BodyWeight = 5, Description = "child1"
                };

                var child2 = new Human {
                    BodyWeight = 6, Description = "child2"
                };

                var friend = new Human {
                    BodyWeight = 20, Description = "friend"
                };

                child1.Mother = mother;
                child1.Father = father;
                mother.AddOffspring(child1);
                father.AddOffspring(child1);

                child2.Mother = mother;
                child2.Father = father;
                mother.AddOffspring(child2);
                father.AddOffspring(child2);

                father.Friends = new[] { friend };

                await(session.SaveAsync(mother, cancellationToken));
                await(session.SaveAsync(father, cancellationToken));
                await(session.SaveAsync(child1, cancellationToken));
                await(session.SaveAsync(child2, cancellationToken));
                await(session.SaveAsync(friend, cancellationToken));

                await(txn.CommitAsync(cancellationToken));
                session.Close();
            }
Ejemplo n.º 3
0
			public void Prepare()
			{
				ISession session = tc.OpenNewSession();
				ITransaction txn = session.BeginTransaction();

				var mother = new Human {BodyWeight = 10, Description = "mother"};

				var father = new Human {BodyWeight = 15, Description = "father"};

				var child1 = new Human {BodyWeight = 5, Description = "child1"};

				var child2 = new Human {BodyWeight = 6, Description = "child2"};

				var friend = new Human {BodyWeight = 20, Description = "friend"};

				child1.Mother = mother;
				child1.Father = father;
				mother.AddOffspring(child1);
				father.AddOffspring(child1);

				child2.Mother = mother;
				child2.Father = father;
				mother.AddOffspring(child2);
				father.AddOffspring(child2);

				father.Friends = new[] {friend};

				session.Save(mother);
				session.Save(father);
				session.Save(child1);
				session.Save(child2);
				session.Save(friend);

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