Inheritance: OptimizedPersistable
Exemplo n.º 1
0
 public Person(Person person = null) // creates a random Person object
 {
   int r = randGen.Next(99999);
   firstName = r.ToString();
   r = randGen.Next(99999999);
   lastName = r.ToString();
   VelocityDbList<Person> personList = new VelocityDbList<Person>();
   if (person != null && person.IsPersistent)
   {
     personList.Persist(person.Session, person);
     personList.Add(person);
     friendsRef = new WeakIOptimizedPersistableReference<VelocityDbList<Person>>(personList);
   }
 }
Exemplo n.º 2
0
 const long numberOfPersons = 10000000000; // a billion Person objects - let's say it is more than we can fit in memory
 static void Main(string[] args)
 {
   try
   {
     using (SessionNoServer session = new SessionNoServer(s_systemDir))
     {
       Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
       session.BeginUpdate();
       Person person = new Person();
       for (long i = 0; i < numberOfPersons; i++)
       {
         // Each WeakIOptimizedPersistableReference require a persisted object (non null Oid) so that object reference can be substituted with an Oid.
         session.Persist(person);
         // create new Person and make prior Person his/her friend (see constructor of Person)
         person = new Person(person);
       }
       session.Commit();
     }
   }
   catch (Exception ex)
   {
     Console.WriteLine(ex.ToString());
   }
 }