Domain Model I am working on has root aggregate and child entities. Something like the following code:
class Order
{
IList Lines {get;se
The pattern I use is:
class Order
{
private List lines = new List();
IEnumerable Lines { get { return this.lines; } }
void AddLine(OrderLine line)
{
this.orders.Add(line);
}
}
If you're using NET 3.5 you get all the search functionality you could want for IEnumerable using LINQ, and you hide your collection implementation.
The problem with returning OrderLine[] is that your collection can be modified externally eg:
Order.Lines[0] = new OrderLine().