Exemplo n.º 1
0
        private void CreateTestContext()
        {
            var t1 = new ForumThread {
                Id = 1, Name = "Thread 1"
            };
            var t2 = new ForumThread {
                Id = 2, Name = "Thread 2"
            };
            var m1 = new ForumMessage {
                Id = 1, Name = "Thread 1: Message 1", ForumThread = t1
            };
            var m2 = new ForumMessage {
                Id = 2, Name = "Thread 1: Message 2", ForumThread = t1
            };
            var m3 = new ForumMessage {
                Id = 3, Name = "Thread 2: Message 1", ForumThread = t2
            };

            t1.Messages.Add(m1);
            t1.Messages.Add(m2);
            t2.Messages.Add(m3);

            using (ISession session = OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(t1);
                    session.Save(t2);

                    transaction.Commit();
                }
            }
        }
Exemplo n.º 2
0
        private async Task CreateTestContextAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            var t1 = new ForumThread {
                Id = 1, Name = "Thread 1"
            };
            var t2 = new ForumThread {
                Id = 2, Name = "Thread 2"
            };
            var m1 = new ForumMessage {
                Id = 1, Name = "Thread 1: Message 1", ForumThread = t1
            };
            var m2 = new ForumMessage {
                Id = 2, Name = "Thread 1: Message 2", ForumThread = t1
            };
            var m3 = new ForumMessage {
                Id = 3, Name = "Thread 2: Message 1", ForumThread = t2
            };

            t1.Messages.Add(m1);
            t1.Messages.Add(m2);
            t2.Messages.Add(m3);

            using (ISession session = OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    await(session.SaveAsync(t1, cancellationToken));
                    await(session.SaveAsync(t2, cancellationToken));

                    await(transaction.CommitAsync(cancellationToken));
                }
            }
        }
Exemplo n.º 3
0
		private void CreateTestContext()
		{
			var t1 = new ForumThread {Id = 1, Name = "Thread 1"};
			var t2 = new ForumThread {Id = 2, Name = "Thread 2"};
			var m1 = new ForumMessage {Id = 1, Name = "Thread 1: Message 1", ForumThread = t1};
			var m2 = new ForumMessage {Id = 2, Name = "Thread 1: Message 2", ForumThread = t1};
			var m3 = new ForumMessage {Id = 3, Name = "Thread 2: Message 1", ForumThread = t2};

			t1.Messages.Add(m1);
			t1.Messages.Add(m2);
			t2.Messages.Add(m3);

			using (ISession session = OpenSession())
			{
				using (ITransaction transaction = session.BeginTransaction())
				{
					session.Save(t1);
					session.Save(t2);

					transaction.Commit();
				}
			}
		}