New Posts New Posts RSS Feed: Assigning value to key field in table
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Assigning value to key field in table

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: Assigning value to key field in table
    Posted: 06-Apr-2008 at 8:51pm
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
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 07-Apr-2008 at 1:01pm
forget it.  I solved it.
 
aEventStep["EventID"] = eventId;
aEventStep["EventStepId"] = stepId;
 
 
Bill
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down