Пример #1
0
    public void LazyLoadProperty()
    {
      UInt64 id;
      using (SessionNoServer session = new SessionNoServer(systemDir))
      {
        session.BeginUpdate();
        LazyLoadPropertyClass lazy = null;
        for (uint i = 1; i <= 10000; i++)
          lazy = new LazyLoadPropertyClass(i, lazy);
        session.Persist(lazy);
        id = lazy.Id;
        session.Commit();
      }

      using (SessionNoServer session = new SessionNoServer(systemDir))
      {
        UInt32 ct = 10000;
        session.BeginRead();
        LazyLoadPropertyClass lazy = (LazyLoadPropertyClass)session.Open(id);
        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 LazyLoadPropertyClass(UInt32 ct, LazyLoadPropertyClass aRef)
 {
     myRef   = aRef;
     this.ct = ct;
 }
 public LazyLoadPropertyClass(UInt32 ct, LazyLoadPropertyClass aRef)
 {
   myRef = aRef;
   this.ct = ct;
 }