I am trying to get into LINQ to objects, as I can see its power. Fortunately, I have a question that, in my opinion, LINQ should solve.
Here is the question (details are an example);
public class SchoolClass { public int ID; public string Name; public string Teacher; public string RoomName; public string Student_Name; public int Student_Age; }
As you can see from the example, there is a one-to-many relationship between ClassName, Teacher and Room and students, i.e. there are potentially many students in one class.
If we have a list, can LINQ create a list but have only one instance identifier, name, teacher, room name, and ArrayList from Student_Name and Age?
By producing this:
public class Students { public string Student_Name; public int Student_Age; } public class SchoolClass { public int ID; public string Name; public string Teacher; public string RoomName; public ArrayList Students; }
Essentially using LINQ to clear the list to a more logical structure?
To give an example in this example. The second structure is used by the DataGrid to create a Teacher-Child relationship. We save SchoolClass and StudentInformation in classes as shown above. It would be nice to use LINQ to be able to convert our initial list into a structure that a DataGrid can use.
source share