public void Update()
        {
            var v = new EntityWithLifecycle("Shinobi", 10, 10);

            using (ISession s = OpenSession())
            {
                s.Save(v);
                s.Flush();
            }

            // update detached
            Sfi.Statistics.Clear();
            v.Heigth = 0;
            using (ISession s = OpenSession())
            {
                s.Update(v);
                s.Flush();
            }
            Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(0));

            // cleanup
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdate();
                    tx.Commit();
                }
        }
Ejemplo n.º 2
0
		public void SaveOrUpdateCopy()
		{
			var v = new EntityWithLifecycle("Shinobi", 10, 10);
			using (ISession s = OpenSession())
			{
				s.Save(v);
				s.Flush();
			}
			v.Heigth = 0;
			sessions.Statistics.Clear();
			using (ISession s = OpenSession())
			{
				s.SaveOrUpdateCopy(v);
				s.Flush();
			}
			Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0));

			var v1 = new EntityWithLifecycle("Shinobi", 0, 10);
			using (ISession s = OpenSession())
			{
				s.SaveOrUpdateCopy(v1);
				s.Flush();
			}
			Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(0));
			Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0));


			// cleanup
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdate();
				tx.Commit();
			}
		}
Ejemplo n.º 3
0
		public void Save()
		{
			sessions.Statistics.Clear();
			using (ISession s = OpenSession())
			{
				s.Save(new EntityWithLifecycle());
				s.Flush();
			}
			Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(0));

			var v = new EntityWithLifecycle("Shinobi", 10, 10);
			using (ISession s = OpenSession())
			{
				s.Save(v);
				s.Delete(v);
				s.Flush();
			}
		}
        public void Save()
        {
            Sfi.Statistics.Clear();
            using (ISession s = OpenSession())
            {
                s.Save(new EntityWithLifecycle());
                s.Flush();
            }
            Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(0));

            var v = new EntityWithLifecycle("Shinobi", 10, 10);

            using (ISession s = OpenSession())
            {
                s.Save(v);
                s.Delete(v);
                s.Flush();
            }
        }
Ejemplo n.º 5
0
        public async Task SaveAsync()
        {
            Sfi.Statistics.Clear();
            using (ISession s = OpenSession())
            {
                await(s.SaveAsync(new EntityWithLifecycle()));
                await(s.FlushAsync());
            }
            Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(0));

            var v = new EntityWithLifecycle("Shinobi", 10, 10);

            using (ISession s = OpenSession())
            {
                await(s.SaveAsync(v));
                await(s.DeleteAsync(v));
                await(s.FlushAsync());
            }
        }
Ejemplo n.º 6
0
        public async Task DeleteAsync()
        {
            var v = new EntityWithLifecycle("Shinobi", 10, 10);

            using (ISession s = OpenSession())
            {
                await(s.SaveAsync(v));
                await(s.FlushAsync());
                Sfi.Statistics.Clear();
                v.Heigth = 0;
                await(s.DeleteAsync(v));
                await(s.FlushAsync());
                Assert.That(Sfi.Statistics.EntityDeleteCount, Is.EqualTo(0));
            }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdateAsync());
                    await(tx.CommitAsync());
                }
        }