Exemplo n.º 1
0
		public void CanUseUniqueResultWithNullableType_ReturnNull_HQL()
		{
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				Person p = new Person("a", null, 4);
				s.Save(p);
				tx.Commit();
			}

			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				int? result = s.CreateQuery("select p.IQ from Person p")
					.UniqueResult<int?>();
				Assert.IsNull(result);
				tx.Commit();
			}

			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				s.Delete("from Person");
				tx.Commit();
			}
		}
Exemplo n.º 2
0
		public void CanUseUniqueResultWithNullableType_ReturnResult_Criteria()
		{
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				Person p = new Person("a", 4, 4);
				s.Save(p);
				tx.Commit();
			}

			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				int? result = s.CreateCriteria(typeof(Person))
					.SetProjection(Projections.Property("IQ"))
					.UniqueResult<int?>();
				Assert.AreEqual(4, result);
				tx.Commit();
			}

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