示例#1
0
        public void SavingAndRetrieving()
        {
            Guid rowId = Guid.NewGuid();

            var entity = new VendorCatalog
            {
                Name      = "Dario",
                CatalogID = rowId,
                Catalog   = Convert.ToBytes("Aqui me pongo a cantar...al compas de la viguela")
            };

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

            VendorCatalog entityReturned = null;

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    entityReturned = s.CreateQuery("from VendorCatalog").UniqueResult <VendorCatalog>();

                    Assert.AreEqual("Dario", entityReturned.Name);
                    Assert.AreEqual(rowId.ToString(), entityReturned.CatalogID.ToString());
                    Assert.AreEqual("Aqui me pongo a cantar...al compas de la viguela", Convert.ToStr(entityReturned.Catalog));
                }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    s.Delete(entityReturned);
                    tx.Commit();
                }
        }
示例#2
0
		public void SavingAndRetrieving()
		{
			Guid rowId = Guid.NewGuid();

			var entity = new VendorCatalog
			             	{
			             		Name = "Dario",
			             		CatalogID = rowId,
			             		Catalog = Convert.ToBytes("Aqui me pongo a cantar...al compas de la viguela")
			             	};

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

			VendorCatalog entityReturned = null;
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				entityReturned = s.CreateQuery("from VendorCatalog").UniqueResult<VendorCatalog>();

				Assert.AreEqual("Dario", entityReturned.Name);
				Assert.AreEqual(rowId.ToString(), entityReturned.CatalogID.ToString());
				Assert.AreEqual("Aqui me pongo a cantar...al compas de la viguela",Convert.ToStr(entityReturned.Catalog));
			}

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