public async Task RefreshCascadeAsync()
        {
            using (ISession session = OpenSession())
            {
                using (ITransaction txn = session.BeginTransaction())
                {
                    JobBatch batch = new JobBatch(DateTime.Now);
                    batch.CreateJob().ProcessingInstructions = "Just do it!";
                    batch.CreateJob().ProcessingInstructions = "I know you can do it!";

                    // write the stuff to the database; at this stage all job.status values are zero
                    await(session.PersistAsync(batch));
                    await(session.FlushAsync());

                    // behind the session's back, let's modify the statuses
                    await(UpdateStatusesAsync(session));

                    // Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements
                    await(session.RefreshAsync(batch));

                    foreach (Job job in batch.Jobs)
                    {
                        Assert.That(job.Status, Is.EqualTo(1), "Jobs not refreshed!");
                    }

                    await(txn.RollbackAsync());
                }
            }
        }
Esempio n. 2
0
		public void RefreshCascade()
		{
			using(ISession session = OpenSession())
			{
				using (ITransaction txn = session.BeginTransaction())
				{
					JobBatch batch = new JobBatch(DateTime.Now);
					batch.CreateJob().ProcessingInstructions = "Just do it!";
					batch.CreateJob().ProcessingInstructions = "I know you can do it!";

					// write the stuff to the database; at this stage all job.status values are zero
					session.Persist(batch);
					session.Flush();

					// behind the session's back, let's modify the statuses
					UpdateStatuses(session);

					// Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements
					session.Refresh(batch);

					foreach (Job job in batch.Jobs)
					{
						Assert.That(job.Status, Is.EqualTo(1), "Jobs not refreshed!");
					}

					txn.Rollback();
				}
			}
		}
        public async Task RefreshIgnoringTransientInCollectionAsync()
        {
            using (ISession session = OpenSession())
            {
                using (ITransaction txn = session.BeginTransaction())
                {
                    var batch = new JobBatch(DateTime.Now);
                    batch.CreateJob().ProcessingInstructions = "Just do it!";
                    await(session.PersistAsync(batch));
                    await(session.FlushAsync());

                    batch.CreateJob().ProcessingInstructions = "I know you can do it!";
                    await(session.RefreshAsync(batch));
                    Assert.That(batch.Jobs.Count == 1);

                    await(txn.RollbackAsync());
                }
            }
        }
Esempio n. 4
0
		public void RefreshIgnoringTransientInCollection()
		{
			using (ISession session = OpenSession())
			{
				using (ITransaction txn = session.BeginTransaction())
				{

					var batch = new JobBatch(DateTime.Now);
					batch.CreateJob().ProcessingInstructions = "Just do it!";
					session.Persist(batch);
					session.Flush();

					batch.CreateJob().ProcessingInstructions = "I know you can do it!";
					session.Refresh(batch);
					Assert.That(batch.Jobs.Count == 1);

					txn.Rollback();
				}
			}
		}