This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have Registry class with EntityCollection RegistryAssignments.
When I add new RegistryAssignment to RegistryAssignments like this
// Load Registry from DB
Registry r = //load Registry from DB
RegistryAssignment regAssignment = new RegistryAssignment();
r.RegistryAssignments.Add(regAssignment);
SaveChanges method fails with ORA error "Parent key not found".
But when I manualy set RegistryAssignment's RegistryId property (FK) SaveChanges
method succesfully completes.
Shouldn't EntityCollection's Add method set RegistryId for me?
|
|
|
Yes, it should. Could you provide us with a small application (including LightSpeedContext configuration and Oracle CREATE TABLE scripts) that reproduces the problem? We have been unable to reproduce the behaviour ourselves -- adding a new child to a parent's collection correctly sets the child's parent ID property as well. Thanks! |
|
|
Problem resolved. Add method on EntityCollection works as it should. Problem was that Registry instance has been stored/restored in Microsoft.Practices.PageFlow.UserData before I tried to add new RegistryAssignment to RegistryAssignments EntityCollection. As soon I moved Registry instance to ASP.NET session problem disappeared. Does this mean that LightSpeed has some problems with serialization/deserialization?
|
|
|
LightSpeed shouldn't have any problems with serialisation/deserialisation -- the Entity type and all designer-generated classes are marked as [Serializable]. However some care is required when deserialising entities that were created in a previous request because the unit of work is not serialisable. It is therefore sometimes necessary to explicitly reattach objects to a new unit of work when they are rehydrated from a serialised state. See http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=1621 and http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=1570 for more (rather lengthy at times!) discussion and examples of the sort of issues that can arise. I am not familiar with PageFlow.UserData so I am not sure if serialisation is the problem but if you expect to need to support Web farms or failover configurations then I would advise testing your session solution in a "state service" or "state database" configuration just in case, because in those configurations ASP.NET session state also depends on serialising and rehydrating the objects. |
|