public void SavingAndRetrieving()
		{
			var ticks = new TimeSpan(1982);

			var entity = new TimeSpanClass
			             	{
			             		TimeSpanValue = ticks
			             	};

			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				s.Save(entity);
				tx.Commit();
			}

			TimeSpanClass entityReturned;

			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				entityReturned = s.CreateQuery("from TimeSpanClass").UniqueResult<TimeSpanClass>();
				Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
			}

			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				s.Delete(entityReturned);
				tx.Commit();
			}
		}
Beispiel #2
0
        public void SavingAndRetrieving()
        {
            var ticks = new TimeSpan(1982);

            var entity = new TimeSpanClass
            {
                TimeSpanValue = ticks
            };

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    s.Save(entity);
                    tx.Commit();
                }

            TimeSpanClass entityReturned;

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    entityReturned = s.CreateQuery("from TimeSpanClass").UniqueResult <TimeSpanClass>();
                    Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
                }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    s.Delete(entityReturned);
                    tx.Commit();
                }
        }
Beispiel #3
0
        public async Task SavingAndRetrievingAsync()
        {
            var ticks = new TimeSpan(1982);

            var entity = new TimeSpanClass
            {
                TimeSpanValue = ticks
            };

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(s.SaveAsync(entity));
                    await(tx.CommitAsync());
                }

            TimeSpanClass entityReturned;

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    entityReturned = await(s.CreateQuery("from TimeSpanClass").UniqueResultAsync <TimeSpanClass>());
                    Assert.AreEqual(ticks, entityReturned.TimeSpanValue);
                }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(s.DeleteAsync(entityReturned));
                    await(tx.CommitAsync());
                }
        }