473,800 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1417
> 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
924
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 other properties. Then a MenuItems class which inheritscollection base and implements ienumerator. The MenuItems classholds a collection of MenuItem objects. Ok. Fine. Now, I will be having a nested menu, like Products ->Division -> Category ->...
6
3262
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 query-string flag is used to indicate to the page whether it should instantiate a new instance of the object or access an existing instance from the calling page. On the both pages I have a property of the page which is an instance of this custom...
2
1502
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 other properties. Then a MenuItems class which inheritscollection base and implements ienumerator. The MenuItems classholds a collection of MenuItem objects. Ok. Fine. Now, I will be having a nested menu, like Products ->Division -> Category ->...
8
2023
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 like so: <Teachers> <Teacher> <Classes> <Class>
0
1837
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 'School.Teacher' as an ArrayList creates the proper information (see aspx code below), but I'm unable to use this ArrayList in the Profile object. The aspx code below shows the attempt and error message.
2
3853
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: You must implement a default accessor on System.Web.Security.MembershipUserCollection because it inherits from ICollection. The error appears when trying to load the WebService.asmx file. The code builds fine.
9
3806
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 techniques are not feasible) The question is; Given that I have a Person object with a private set for id. What is the recommended approac in passing that object to the web service
4
1567
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 it's inside of. What I have is a custom object called Ageload which contains a custom collection designed to hold another custom object called a Batch. (Ageload, BatchCollection, Batch) When I use a dataset with a table in it, I can do...
2
4280
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 Property1 As String Public Property2 As Integer Public Property myCollection1 As Arraylist (Actually, it will be a strongly
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10274
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.