How to use the generated code

By Stephan Meyn

Thursday, October 23, 2003

Take a look at the class Person.cs

right at the top you will notice the following variables

internal int _PersonID;
private string _FirstName;
private string _Permission;
private string _SurName;

These are the value attributes. For each of these there is a corresponding property, E.g:

public virtual string FirstName {

get { return _FirstName;}
set { _FirstName = value;} }

You will notice however that PersonID does not have a set method.

///
/// Primary Key Attribute
///
public virtual int PersonID {
get {return _PersonID;}
} 

When generating the class BambooBuilder recognised it as a primary key and decided to make it an auto-number key field. Hence you cannot change the id (unless you run the loader functions where you have to make sure no collisions occur).

You notice that there is not much more to this class. It is a very light weight value object.

The functionality to create, read, update and delete object are all located in the class IssueTrackRoot:

For each value object (or business object), there are four methods:

public virtual Person Insert(Person newPerson)

public virtual Person GetPerson(int PersonID)
public virtual Person Update(Person source)
public virtual void Delete(ActionItem ActionItemToDelete)

As you can see these are pretty straight forward functions.

Here is how you use them:
IssueTrackRoot root = ....
Person p = new Person("John", "Smith", "Manager");
p = root.Add(p);
// now p has an id
Person retrievedP = root.Get(p.ID);
retrievedP.Permission = "Guest";
root.Update(retrievedP);
// now delete the item from the store
root.Delete(retrievedP);
// while you still have a copy, it is no longer in the Bamboo storage.
There you have a complete lifecycle of a person.