Click here to Skip to main content
15,895,922 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When I call the Save() method throw exception "Can not directly save a child object", how to save a child object?
Posted
Updated 26-May-11 17:20pm
v2
Comments
thatraja 26-May-11 23:21pm    
CSLA?

1 solution

I'm answering this because I was curious what CSLA was. In 16.3 seconds I learned:

The very definition of a child object is that it is persisted as part of its parent. That's a fancy way of saying that you can't save a child object, because that's how CSLA is designed.

Even if you defeat the normal protections around saving a child object (and you can), you'd confuse the parent object and that would cause other problems.

If you need to save this object directly, then it is a root object, not a child object. And if that's the case, then the object can't be contained by another object, it must stand alone.
-- Rockford Lhotka, creator of CSLA
http://forums.lhotka.net/forums/t/7201.aspx[^]
http://forums.lhotka.net/forums/p/5361/26017.aspx[^]
 
Share this answer
 
Comments
tpywocao 27-May-11 5:13am    
"If you need to save this object directly, then it is a root object, not a child object."

I know!But,how can I do this?
Yvan Rodrigues 27-May-11 9:25am    
You might get an answer here, but it's unlikely. I would strongly suggest posting on the CSLA support forums if you haven't already: http://forums.lhotka.net/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900