Nested Collections

Nested Collections

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


calcBO posted on Wednesday, January 19, 2011

I’m an old 1.x CSLA user and it’s been a while since I’ve had to design some new objects.  I’m trying to nest collections. Is this possible?

 

Thanks! 

Public Class A

    Inherits BusinessCollectionBase

    Default Public ReadOnly Property Item(ByVal Index As Integer) As Class B

    Public Property GroupName

End Class

 Public Class B

    Inherits BusinessCollectionBase

    Default Public ReadOnly Property Item(ByVal Index As Integer) As Class C

    Public Property Person

 End Class

 

 Public Class C

    inherits BusinessBase

    Public Property RequestType

    Public Property Request

 End Class

 

RockfordLhotka replied on Wednesday, January 19, 2011

You can't directly nest collections, because BusinessListBase can only contain BusinessBase child objects.

In other words, the child item in a list must be an object. But that object can have a child collection. So it can look like this:

BB -> BLB -> BB -> BLB -> BB

So yes, you can nest collections, just with intermediate node objects.

calcBO replied on Wednesday, January 19, 2011

Thanks for the help!

Copyright (c) Marimer LLC