473,379 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Custom Object that has 'nested' collections

a
The problem:

I want to allow an administrator (user) to create a list of teachers, each
teacher in turn has a list of classes, each class has a list of students.

There's an article at http://aspalliance.com/721 that describes making
classes for the Student and the StudentList, but I'm wondering how to make
classes that are collections of the other classes, ie a ClassList that holds
the StudentList class and a TeacherList class that holds the ClassList class.

TeacherList-->ClassList-->StudentList-->Student

What is the approach to use to make a custom object that could handle this
nesting?

The article mentioned above has a StudentList Class that inherits from
IEnumerable and uses a Hastable to hold the Student objects that are made up
of simple data types. I tried making classes in a similar fashion for the
ClassList and StudentList collections, but I'm having casting errors, so I'm
not sure that this is the correct approach or my implementation is not
correct.

Anyone have any ideas or suggestions as to how to nest collections like
this? or another approach to accomplish the same thing? If you want to see
the code I've tried, I can post it.

Thanks,

Paul

Feb 7 '06 #1
2 1402
> The problem:

I want to allow an administrator (user) to create a list of teachers,
each teacher in turn has a list of classes, each class has a list of
students.

There's an article at http://aspalliance.com/721 that describes making
classes for the Student and the StudentList, but I'm wondering how to
make classes that are collections of the other classes, ie a ClassList
that holds the StudentList class and a TeacherList class that holds
the ClassList class.

TeacherList-->ClassList-->StudentList-->Student

What is the approach to use to make a custom object that could handle
this nesting?

The article mentioned above has a StudentList Class that inherits from
IEnumerable and uses a Hastable to hold the Student objects that are
made up of simple data types. I tried making classes in a similar
fashion for the ClassList and StudentList collections, but I'm having
casting errors, so I'm not sure that this is the correct approach or
my implementation is not correct.

Anyone have any ideas or suggestions as to how to nest collections
like this? or another approach to accomplish the same thing? If you
want to see the code I've tried, I can post it.

Thanks,

Paul


I imagine that your problem lies in the fact that what you wrote above is
false. And your probably confused. This problem has nothing to do with nesting.

A TeacherList would not hold a ClassList.

A TeacherList has 0-n Teacher objects.
A Teacher has 1 ClassList
A ClassList has 0-n Class objects.
A Class has 1 StudentList
A StudentList has 1-n Student objects.

I would start by defining the "core" objects before worrying about the collections.
Feb 7 '06 #2
a
Chris:

OK, I think I see what you mean.

I'm not familiar with the solution to this question so it's not apparent to
me how to go about it. I'll work on your suggestion.

Thanks,

Paul

-------------------------------------------------------------------------

"chris martin" wrote:
The problem:

I want to allow an administrator (user) to create a list of teachers,
each teacher in turn has a list of classes, each class has a list of
students.

There's an article at http://aspalliance.com/721 that describes making
classes for the Student and the StudentList, but I'm wondering how to
make classes that are collections of the other classes, ie a ClassList
that holds the StudentList class and a TeacherList class that holds
the ClassList class.

TeacherList-->ClassList-->StudentList-->Student

What is the approach to use to make a custom object that could handle
this nesting?

The article mentioned above has a StudentList Class that inherits from
IEnumerable and uses a Hastable to hold the Student objects that are
made up of simple data types. I tried making classes in a similar
fashion for the ClassList and StudentList collections, but I'm having
casting errors, so I'm not sure that this is the correct approach or
my implementation is not correct.

Anyone have any ideas or suggestions as to how to nest collections
like this? or another approach to accomplish the same thing? If you
want to see the code I've tried, I can post it.

Thanks,

Paul


I imagine that your problem lies in the fact that what you wrote above is
false. And your probably confused. This problem has nothing to do with nesting.

A TeacherList would not hold a ClassList.

A TeacherList has 0-n Teacher objects.
A Teacher has 1 ClassList
A ClassList has 0-n Class objects.
A Class has 1 StudentList
A StudentList has 1-n Student objects.

I would start by defining the "core" objects before worrying about the collections.

Feb 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Prakash C via .NET 247 | last post by:
Hi, I am having a problem to create nested collections. I want tocreate a menu for my site. I created a MenuItem class which willstore the text that should appear on hyperlink. It may alsocontain...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
2
by: Prakash C via .NET 247 | last post by:
Hi, I am having a problem to create nested collections. I want tocreate a menu for my site. I created a MenuItem class which willstore the text that should appear on hyperlink. It may alsocontain...
8
by: a | last post by:
I'm trying to save data from a custom object into the profile object, but it is not structured the way that I want. I'm trying to get the custom object to serialize as xml to a Profile object...
0
by: a | last post by:
I need to create an instance of a custom object 'School.Teacher' and use it in a Profile object. I'm developing a bad case of "Pretzel Logic" thinking about this. Filling the custom object ...
2
by: Justin Drerup | last post by:
I'm tryng to return a custom object that contains a collection of MembershipUsers through a web service however I receive the following error when trying to return the object through a web method:...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
4
by: Usarian | last post by:
I am making some custom objects that operate "inside" each other, the way a datatable is available inside a dataset. (VB.NET 1.1) I can't figure out how to make the child object know what object...
2
by: =?Utf-8?B?Y3Nz?= | last post by:
I am new to ASP.net webservice and have a quesiton. Is is possible to pass custom object to a web service (using VB 2005)? My custom object will look like this Public Class Myclass Public...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.