Interim Design Solution Request: Parent Child Relationship without Collection

Interim Design Solution Request: Parent Child Relationship without Collection

Old forum URL: forums.lhotka.net/forums/t/5586.aspx


eulerthegrape posted on Tuesday, October 14, 2008

I have a pretty standard parent child relationship defined but my company wants to limit the number of children to one, for now.  I would like to leave this flexible but not spend much more time than what's required.  Does it make sense to creates a ParentChildren object and validate that there is only one match and further restrict the user through the UI by using a combobox?  Or is there a way to relate parent and child without a collections class.

This may be totally obvious but I've tried implement a GetChild method in my parent with a multi-select sproc and have been met with an IndexOutOfRangeException.

Thanks in advance,
Euler

eulerthegrape replied on Friday, October 17, 2008

I guess I'm merely asking for an example of a child parent relationship where the child is not part of a collection and if this is an advisable data model.

Thanks,
Euler

ajj3085 replied on Friday, October 17, 2008

Sure just make the child a direct member of the parent..

public class MyParent : BusinessBase<MyParent> {
    private static readonly PropertyInfo<MyChild> MyChildProperty =
       RegisterProperty<MyChild>( new PropertyInfo<MyChild>( "MyChild" ) );

      public MyChild Child {
           get { return GetProperty( MyChildProperty ); }
      }
}

eulerthegrape replied on Friday, October 17, 2008

Woops, I guess I should have prefaced my message with the fact that I am not an expert programmer and am using CSLA 2.  Have you created a delegate read-only info class?  Or are PropertyInfo and RegisterProperty part of 3 or 3.5?  Sorry, I'm pretty confused.

But then I wonder, if I create a read only child info class, will I be able to bind this to a combobox?

Thanks

ajj3085 replied on Friday, October 17, 2008

Ahh.. that would be for csla 3.5, setting up a managed child object property.  Prior to that..

private MyChild child;

public MyChild Child {
    get { return child; }
}

Copyright (c) Marimer LLC