Example #1
0
        public void Query()
        {
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    SqlServerCeEntity entity = new SqlServerCeEntity();
                    entity.StringProp = "a small string";
                    entity.BinaryProp = System.Text.ASCIIEncoding.ASCII.GetBytes("binary string");

                    entity.StringClob = new String('a', 8193);
                    entity.BinaryBlob = new byte[8193];

                    s.Save(entity);
                    tx.Commit();
                }

            using (ISession s = OpenSession())
            {
                IList <SqlServerCeEntity> entities =
                    s.CreateCriteria(typeof(SqlServerCeEntity))
                    .Add(Restrictions.Eq("StringProp", "a small string"))
                    .Add(Restrictions.Eq("BinaryProp", System.Text.ASCIIEncoding.ASCII.GetBytes("binary string")))
                    .List <SqlServerCeEntity>();

                Assert.That(entities.Count, Is.EqualTo(1));
            }
        }
Example #2
0
        public void SaveLoad()
        {
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    SqlServerCeEntity entity = new SqlServerCeEntity();
                    entity.StringProp = "a small string";
                    entity.BinaryProp = new byte[100];

                    entity.StringClob = new String('a', 8193);
                    entity.BinaryBlob = new byte[8193];

                    s.Save(entity);
                    tx.Commit();
                }

            using (ISession s = OpenSession())
            {
                SqlServerCeEntity entity =
                    s.CreateCriteria(typeof(SqlServerCeEntity))
                    .UniqueResult <SqlServerCeEntity>();

                Assert.That(entity.StringProp, Is.EqualTo("a small string"));
                Assert.That(entity.BinaryProp.Length, Is.EqualTo(100));

                Assert.That(entity.StringClob, Is.EqualTo(new String('a', 8193)));
                Assert.That(entity.BinaryBlob.Length, Is.EqualTo(8193));
            }
        }
		public void SaveLoad()
		{
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				SqlServerCeEntity entity = new SqlServerCeEntity();
				entity.StringProp = "a small string";
				entity.BinaryProp = new byte[100];

				entity.StringClob = new String('a', 8193);
				entity.BinaryBlob = new byte[8193];

				s.Save(entity);
				tx.Commit();
			}

			using (ISession s = OpenSession())
			{
				SqlServerCeEntity entity =
					s.CreateCriteria(typeof(SqlServerCeEntity))
						.UniqueResult<SqlServerCeEntity>();

				Assert.That(entity.StringProp, Is.EqualTo("a small string"));
				Assert.That(entity.BinaryProp.Length, Is.EqualTo(100));

				Assert.That(entity.StringClob, Is.EqualTo(new String('a', 8193)));
				Assert.That(entity.BinaryBlob.Length, Is.EqualTo(8193));
			}
		}
		public void Query()
		{
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				SqlServerCeEntity entity = new SqlServerCeEntity();
				entity.StringProp = "a small string";
				entity.BinaryProp = System.Text.ASCIIEncoding.ASCII.GetBytes("binary string");

				entity.StringClob = new String('a', 8193);
				entity.BinaryBlob = new byte[8193];

				s.Save(entity);
				tx.Commit();
			}

			using (ISession s = OpenSession())
			{
				IList<SqlServerCeEntity> entities =
					s.CreateCriteria(typeof(SqlServerCeEntity))
						.Add(Restrictions.Eq("StringProp", "a small string"))
						.Add(Restrictions.Eq("BinaryProp", System.Text.ASCIIEncoding.ASCII.GetBytes("binary string")))
						.List<SqlServerCeEntity>();

				Assert.That(entities.Count, Is.EqualTo(1));
			}
		}