public void LazyLoadDepth() { UInt64 id; using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); LazyLoadByDepth lazy = null; for (uint i = 1; i <= 100; i++) lazy = new LazyLoadByDepth(i, lazy); session.Persist(lazy); id = lazy.Id; session.Commit(); } using (SessionNoServer session = new SessionNoServer(systemDir)) { UInt32 ct = 100; session.BeginRead(); LazyLoadByDepth lazy = (LazyLoadByDepth)session.Open(id, false, false, 0); // load only the root of the object graph Assert.AreEqual(ct--, lazy.MyCt); Assert.IsNull(lazy.MyRefPeek); Assert.NotNull(lazy.MyRef); Assert.NotNull(lazy.MyRefPeek); lazy = lazy.MyRef; Assert.AreEqual(ct--, lazy.MyCt); Assert.IsNull(lazy.MyRefPeek); Assert.NotNull(lazy.MyRef); Assert.NotNull(lazy.MyRefPeek); lazy = lazy.MyRef; Assert.AreEqual(ct--, lazy.MyCt); Assert.IsNull(lazy.MyRefPeek); Assert.NotNull(lazy.MyRef); Assert.NotNull(lazy.MyRefPeek); lazy = lazy.MyRef; Assert.AreEqual(ct--, lazy.MyCt); Assert.IsNull(lazy.MyRefPeek); Assert.NotNull(lazy.MyRef); Assert.NotNull(lazy.MyRefPeek); session.Commit(); } }
public LazyLoadByDepth(UInt32 ct, LazyLoadByDepth aRef) { myRef = aRef; this.ct = ct; }