Пример #1
0
        public void TypeOfParametersShouldBeSetCorrectly()
        {
            using (ISession session = OpenSession())
            {
                using (ITransaction tx = session.BeginTransaction())
                {
                    var entity = new DomainClass {
                        Id = 1, Data = "some oldValue data"
                    };
                    session.Save(entity);
                    tx.Commit();
                }
            }
            using (ISession session = OpenSession())
            {
                using (ITransaction tx = session.BeginTransaction())
                {
                    session.GetNamedQuery("replaceQuery").SetString("old", "oldValue").SetString("new", "newValue").ExecuteUpdate();
                    tx.Commit();
                }
                using (ITransaction tx = session.BeginTransaction())
                {
                    var entity = session.Get <DomainClass>(1);

                    Assert.AreEqual("some newValue data", entity.Data);
                    session.Delete(entity);
                    tx.Commit();
                }
            }
        }
Пример #2
0
		public void TypeOfParametersShouldBeSetCorrectly()
		{
			using (ISession session = OpenSession())
			{
				using (ITransaction tx = session.BeginTransaction())
				{
					var entity = new DomainClass {Id = 1, Data = "some oldValue data"};
					session.Save(entity);
					tx.Commit();
				}
			}
			using (ISession session = OpenSession())
			{
				using (ITransaction tx = session.BeginTransaction())
				{
					session.GetNamedQuery("replaceQuery").SetString("old", "oldValue").SetString("new", "newValue").ExecuteUpdate();
					tx.Commit();
				}
				using (ITransaction tx = session.BeginTransaction())
				{
					var entity = session.Get<DomainClass>(1);

					Assert.AreEqual("some newValue data", entity.Data);
					session.Delete(entity);
					tx.Commit();
				}
			}
		}
Пример #3
0
        public async Task TypeOfParametersShouldBeSetCorrectlyAsync()
        {
            using (ISession session = OpenSession())
            {
                using (ITransaction tx = session.BeginTransaction())
                {
                    var entity = new DomainClass {
                        Id = 1, Data = "some oldValue data"
                    };
                    await(session.SaveAsync(entity));
                    await(tx.CommitAsync());
                }
            }
            using (ISession session = OpenSession())
            {
                using (ITransaction tx = session.BeginTransaction())
                {
                    await(session.GetNamedQuery("replaceQuery").SetString("old", "oldValue").SetString("new", "newValue").ExecuteUpdateAsync());
                    await(tx.CommitAsync());
                }
                using (ITransaction tx = session.BeginTransaction())
                {
                    var entity = await(session.GetAsync <DomainClass>(1));

                    Assert.AreEqual("some newValue data", entity.Data);
                    await(session.DeleteAsync(entity));
                    await(tx.CommitAsync());
                }
            }
        }