First off I don't have a choice about the structure of these tables because I am programming against a database used by other apps. I have two tables that are related.
Event - Primary Key EventId
EventStep which is a child of Event and has the EventId + StepID as the Primary Key and a foreign key of EventId back to the parent.
When I create the Event record, I want to retrieve the next value from a table which holds the next EventID.
When the step is created I want to do the following.
public static EventStep Create(PersistenceManager pManager, Int32 eventId, Int32 stepId)
{
EventStep aEventStep = pManager.CreateEntity<EventStep>();
aEventStep.EventID = eventId;
aEventStep.EventStepID = stepId;
aEventStep.TSCreated =
DateTime.Today;
aEventStep.DateOccured =
DateTime.Today;
pManager.AddToManager();
return aEventStep;
}
It tells me that I can't do this because EventId and EventStepId are read-only fields. How do I get around this, other than changing the database which isn't an option at this point in time.
Bill