Additional Code - zip file 488 KB

Listing 1

public class Part {
  private string category;
  private string name;
  private string manufacturer;
  private string manufacturerPartNumber;
  . . .
}

public class PartAssembly : Part {
  private System.Collections.ArrayList components;
  . . .
}


Listing 2

// Open the ObjectContainer
ObjectContainer Database = Db4o.OpenFile(fileName);

// Create a new Part object
Part mb = new Part ( "Motherboard",
  "Desktop Board D945Gnt",
  "Intel",
  "BOXD945GNT");

// Put it in the database
Database.set(mb);

// Commit the transaction and
//  close the database
Database.commit();
Database.close();


Listing 3

// Create a Part template object
Part PartTemplate = new Part (
  null,
  "Desktop Board D945GNT",
  null, null);

// Execute the query
ObjectSet result = Database.get(PartTemp);

// Retrieve the matching object
if(Result.hasNext())  {
  Part mb = (Part) result.next();
  // Do something with the Part
  . . . 
}


Listing 4

// Create a Part template object
Part PartTemplate = new Part (
  null,
  "Desktop Board D945GNT",
  null, null, null);

// Execute the query
ObjectSet result = Database.get(PartTemp);

// Retrieve the matching object
if(Result.hasNext())  {
  Part mb = (Part) result.next();

  // Update the alternateSupplier
  mb.AlternateSupplier = "Dougs Board Outlet";

  // Return the object to the database
  Database.set(mb);
}

Additional Code - zip file 488 KB