Newbie Question

Newbie Question

Old forum URL: forums.lhotka.net/forums/t/6220.aspx


cossy74 posted on Wednesday, January 21, 2009

Hi,

I just need some help desiging my classes.

My D

B is setup like this:

Table: Event ( Primary Key - EventID)

Table:EventItem ( Primary Key - EventItemID; ForiegnKey - EventID )

Simply put the Event contains a list of Event Items. Therefore i assume the Event is a Editable Root class. But what is EventItem? and how do i get the Event to populate the EventItems list?

In the Project Tracker example i cannot see anything like this. The closest is the Project Tracker and Project Resource classes, but every method for populating the Project Resource list takes the Assignment Class.

Can anyone help me?

robert_m replied on Wednesday, January 21, 2009

You need 3 classes:
Event - BusinessBase (root)
EventItems - BusinessListBase (child list of event items)
EventItem (BusinessBase) - child, element of EventItems list

When loading data, Event (root) should do communication with DB, ie. execute something like "SELECT * FROM EventItems WHERE EventID = (own ID)", then hand over the retrieved DataReader or LINQ collection or....(depending on data access technology you use) to the EventItems list.

cossy74 replied on Wednesday, January 21, 2009

Right so far:

public class Event : BusinessBase<Event>

public class EventItems : BusinessListBase<EventItems, EventItem>

public class EventItem : BusinessBase<EventItem>

Is this correct?

What do i do if the EventItem has a EventSubItem list? DOes this change it from an editable child?

rsbaker0 replied on Wednesday, January 21, 2009

No, child objects can have children of their own (arbitrarily deep object graph).

Copyright (c) Marimer LLC