public void SavingAndRetrieving() { var ticks = new TimeSpan(1982); var entity = new TimeSpanClass { TimeSpanValue = ticks }; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Save(entity); tx.Commit(); } TimeSpanClass entityReturned; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { entityReturned = s.CreateQuery("from TimeSpanClass").UniqueResult<TimeSpanClass>(); Assert.AreEqual(ticks, entityReturned.TimeSpanValue); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete(entityReturned); tx.Commit(); } }
public void SavingAndRetrieving() { var ticks = new TimeSpan(1982); var entity = new TimeSpanClass { TimeSpanValue = ticks }; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Save(entity); tx.Commit(); } TimeSpanClass entityReturned; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { entityReturned = s.CreateQuery("from TimeSpanClass").UniqueResult <TimeSpanClass>(); Assert.AreEqual(ticks, entityReturned.TimeSpanValue); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete(entityReturned); tx.Commit(); } }
public async Task SavingAndRetrievingAsync() { var ticks = new TimeSpan(1982); var entity = new TimeSpanClass { TimeSpanValue = ticks }; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { await(s.SaveAsync(entity)); await(tx.CommitAsync()); } TimeSpanClass entityReturned; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { entityReturned = await(s.CreateQuery("from TimeSpanClass").UniqueResultAsync <TimeSpanClass>()); Assert.AreEqual(ticks, entityReturned.TimeSpanValue); } using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { await(s.DeleteAsync(entityReturned)); await(tx.CommitAsync()); } }