Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSLA: child doesn't have a valid parent pointer #368

Closed
GoogleCodeExporter opened this issue Aug 3, 2015 · 7 comments
Closed

CSLA: child doesn't have a valid parent pointer #368

GoogleCodeExporter opened this issue Aug 3, 2015 · 7 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. From root object X create a child object Y
2. Accesing Y.XMember will create a new instance of the root object

What is the expected output? What do you see instead?
Expecting a pointer to the root object instance that created the child.

What version of the product are you using?
1651

Please provide any additional information below.
On occasion I need to a need to access properties (possibly uncommitted) of 
the parent.  This parent should be accessible from the child object 
otherwise I would be forced to pass both objects around all the time. More 
if I'm using grandchildren.




Original issue reported on code.google.com by Batku...@gmail.com on 22 May 2010 at 6:53

Attachments:

@GoogleCodeExporter
Copy link
Author

DB didn't get attached. Attempt 2.

I've just realized that this might be even more interesting.  Should you be 
able to 
modify the child FK pointing to it's parent?  In other words allow a *child* to 
change 
parents.  



Original comment by Batku...@gmail.com on 23 May 2010 at 2:20

Attachments:

@GoogleCodeExporter
Copy link
Author

Original comment by bniemyjski on 26 May 2010 at 1:23

  • Changed state: Accepted
  • Added labels: Framework-CSLA, Type-Defect

@GoogleCodeExporter
Copy link
Author

I've also added an issue around child objects. See 
http://code.google.com/p/codesmith/issues/detail?id=394. Not sure if we are 
tripping over each other here.

Original comment by JenasysD...@gmail.com on 9 Jun 2010 at 11:36

@GoogleCodeExporter
Copy link
Author

Original comment by bniemyjski on 19 Jun 2010 at 9:23

  • Changed state: Investigating

@GoogleCodeExporter
Copy link
Author

Hello,

I spent about two hours looking into this, and I couldn't find a decent 
solution. I did come across these three posts:

http://forums.lhotka.net/forums/p/6210/43595.aspx
http://forums.lhotka.net/forums/t/5131.aspx
http://forums.lhotka.net/forums/p/2672/13793.aspx

There seems to be a lot of work you need to do to enable this. And it seems 
like it should be simple and handled by CSLA.

I took a look and I think the best spot to handle setting this would be in the 
Lists AddNewCore.

 protected override object AddNewCore()
        {
            Admission item = CSLATest.Business.Admission.NewAdmission();

            bool cancel = false;
            OnAddNewCore(ref item, ref cancel);
            if (!cancel)
            {
                // Check to see if someone set the item to null in the OnAddNewCore.
                if(item == null)
                    item = CSLATest.Business.Admission.NewAdmission();

                // Pass the parent value down to the child.
                Patient patient = this.Parent as Patient;
                if (patient != null)
                    item.PatientMember = patient;

                Add(item);
            }

            return item;
        }

You would also need to think about what happens if you are not using a List... 
In the scenario above, I had set a setter on the collection like so:

            internal set
            {
                PatientID = value.PatientID;
                LoadProperty(_patientMemberProperty, value);
            }

I really don't like this setup and I'm not happy with it. Apart from this, it 
leads you into a StackOverflow when you try to call Save(). If someone can look 
into this and supply a working sample in code that handles serialization, 
children and children collections. I would have no problem opening this back up 
and implementing.

I'd suggest, opening a forum post on Rockys site for discussion.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 8 Jul 2010 at 8:55

  • Changed state: UnderConsideration

@GoogleCodeExporter
Copy link
Author

Hello,

I have asked this in the forums 
(http://forums.lhotka.net/forums/p/9204/43699.aspx#43699)

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 14 Jul 2010 at 5:34

@GoogleCodeExporter
Copy link
Author

Original comment by bniemyjski on 15 Jul 2010 at 3:48

  • Changed state: Accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants