Hi,
Coming from a primitive language like ansi-C,I'm new to C# so I really need your help. How do I write a function
that would loop through a given dataset and populate the list of courses tied up to the student,
then loop through the subjects tied up to the given course?
StudentName Age Courses SubjectsList
Prasad Singh 23 Bachelor of Arts Subject 1
Prasad Singh 23 Bachelor of Business Subject 11
Prasad Singh 23 Bachelor of Arts Subject 2
Prasad Singh 23 Bachelor of Business Subject 22
Nand Sawadi 42 Bachelor of Arts Subject 8
Nand Sawadi 42 Bachelor of Engg Subject 9
Rajaned Motupah 19 Diploma in Math Subject 10
Rajaned Motupah 19 Diploma in Press Subject 11
Rajaned Motupah 19 Diploma in Tourism Subject 142
Rajaned Motupah 19 Diploma in Tourism Subject 115
Mayar Karan 22 Certificate in English Subject 25
Class Student
{
String Name {get;set;}
Integer Age {get;set;}
List
??? should I define another LIST here for subjects??
}
Thanks in advance for the help.
VulpesPosted Jan 10, 2012, 6:14 AM
Try the following:
Gee BatolPosted Jan 11, 2012, 7:58 PM
The dataset is created and ready by a stored procedure call, but some of the columns are redundant for that particular row, although one row is unique from each other, just some repeating columns. So Vulpes code is very helpful for me to figure out a Class design to layer the output.
Basically the final returned data is of a List<> form, so when I use this in a web service, the XML (soap output) will already be layered because of the list property.
Thanks guys.
Sam HobbsPosted Jan 11, 2012, 6:02 AM
If the data is coming from database tables, then you can create a SQL query to join the tables. That wouold make everything easier.
Even if the data is not coming from database tables, an alternative to what you are doing is to create a database in memory. More specifically, you can use the DataSet class cand create two tables with a relation between the tables. You could then use SQL the same as if the data was in a database.
VulpesPosted Jan 11, 2012, 5:19 AM
Layering is a good word to describe the process.
Gee BatolPosted Jan 10, 2012, 11:05 PM
Your code is very helpful. Very much appreciated!
Thank you!