I have objects/object collections ( CollectionBase ) here:
5/24/2006
Custom Objects/Collections and Tiered Development
http://sholliday.spaces.live.com/blog/
You don't want ot have a method like:
> Private Function Get_Data()
which mixes objects and database access.
Car should be an object
CarCollection should be an object
Wheel should be an object
WheelCollection should be an object
Car should have Wheels as a property.
Don't mix objects and collections with database access.
Create a Manager or Controller class
CarController
public static(shared) CarCollection GetCars
//here is where you create a new CarCollection, and looop over your
datareader to put new cars into the car collection
....................
I have Customer(s) and Order(s) objects, and collections are the url above.
"Big Charles" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I would like to create an array-class to be able to call like:
>
> Dim oMyCar as New MyCar
>
> ' After initializing oMyCar, the object has to be like:
> oMyCar(0).Brand
> oMyCar(0).Wheels.NumberOfWheels
> oMyCar(0).Wheels.ColorOfWheels
>
> oMyCar(1).Brand
> oMyCar(1).Wheels.NumberOfWheels
> oMyCar(1).Wheels.ColorOfWheels
>
> The object has to be an array list itself with properties like Brand
> and sub-objects like Wheels.
>
> I think I should create the class like this:
>
> Public Class MyCar
>
> Inherits CollectionBase
>
> Public Wheels As MyWheels
> Private mBrand As String
>
> Public Sub New()
>
> Get_Data()
>
> End Sub
> Private Function Get_Data()
>
> ' DataReader dr has been populated
>
> If dr.HasRows Then
> While dr.Read
>
> ' I am not sure how to create the array object from here
> Me.Add()
> mBrand = dr.Item("Brand").ToString()
>
> End While
>
> Wheels = New MyWheels(mBrand)
> End If
>
> dr.Close()
> End Function
>
> Sub Add(ByVal il As Object)
> Me.List.Add(il)
> End Sub
>
> Public Property Brand() As String
> Get
> Return mDescripcion
> End Get
> Set(ByVal Value As String)
> mDescripcion = Value
> End Set
> End Property
> End Class
>