Esempio n. 1
0
		public void WorkBut()
		{
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				s.Save(new CustomerNoSmart("Somebody"));
				CustomerNoSmart c = new CustomerNoSmart("Somebody else");
				c.Category = new CustomerCategory("User");
				s.Save(c.Category);
				s.Save(c);
				tx.Commit();
			}

			using (ISession s = OpenSession())
			{
				IList result = s.CreateQuery("select c.Name, cat.Name from CustomerNoSmart c left outer join c.Category cat").List();
				Assert.That(result.Count, Is.EqualTo(2));
			}

			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				s.Delete("from CustomerNoSmart");
				s.Delete("from Category");
				tx.Commit();
			}
		}
Esempio n. 2
0
        public async Task WorkButAsync()
        {
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(s.SaveAsync(new CustomerNoSmart("Somebody")));
                    CustomerNoSmart c = new CustomerNoSmart("Somebody else");
                    c.Category = new CustomerCategory("User");
                    await(s.SaveAsync(c.Category));
                    await(s.SaveAsync(c));
                    await(tx.CommitAsync());
                }

            using (ISession s = OpenSession())
            {
                IList result = await(s.CreateQuery("select c.Name, cat.Name from CustomerNoSmart c left outer join c.Category cat").ListAsync());
                Assert.That(result.Count, Is.EqualTo(2));
            }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(s.DeleteAsync("from CustomerNoSmart"));
                    await(s.DeleteAsync("from Category"));
                    await(tx.CommitAsync());
                }
        }
Esempio n. 3
0
        public void WorkBut()
        {
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    s.Save(new CustomerNoSmart("Somebody"));
                    CustomerNoSmart c = new CustomerNoSmart("Somebody else");
                    c.Category = new CustomerCategory("User");
                    s.Save(c.Category);
                    s.Save(c);
                    tx.Commit();
                }

            using (ISession s = OpenSession())
            {
                IList result = s.CreateQuery("select c.Name, cat.Name from CustomerNoSmart c left outer join c.Category cat").List();
                Assert.That(result.Count, Is.EqualTo(2));
            }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    s.Delete("from CustomerNoSmart");
                    s.Delete("from Category");
                    tx.Commit();
                }
        }