If you are using .NET 2, then I would look at generic collections to store your items:
public class Parent
{
List<Child> _children = new List<Child>();
public int Add(Child value)
{
_children.Add(value);
}
public void LoadAll()
{
// Read the data from the database into something like a datareader
// And populate the child before adding it into the collection...
}
public void Save()
{
foreach (Child child in _children)
{
child.Save();
}
}
}
public class Child
{
// Add the properties...
// Some methods...
public void Save()
{
// Save to database..
}
// Fill the child record.
public static Child Fill(IDataRecord row)
{
Child child = new Child();
child.Id = Convert.ToInt32(row["Id"].ToString());
// Id is a property of Child.
return child;
}
}
This is just a sample of the type of approach you might take. It isn't intended to be directly coded from. -- modified at 4:37 Tuesday 5th December, 2006
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world." Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that." Deja View - the feeling that you've seen this post before.