Welcome back.
Now you know how to reverse, how to sort order and those kind of things of your arrays and lists and.
Well, I enumerable.
But what we're going to do now is something pretty cool.
We are going to combine to lists and put them into a new list.
So it's very similar to combining two tables, but we're doing something with link.
So let's create a new method here.
Let's call it student and university name collection.
So we're going to create a new collection which will not contain the students in a way that we have
them here.
So ID name gender, age and university ID, but more like I want to know the student and the university.
So the student name and the university name.
So I want to know which student name is at which university.
So let's go ahead and build that.
And we create a new collection so far, new collection which will take student in students.
So another for each loop.
And it's going to join university
university and Univer cities on our student thought university ID equals university.
Thought I'd and we're going to order them by their name.
So.
Student Dot name.
And now what I want to do is I want to select them and create a new list out of it.
So new student name is equal to student dot name and university
name is equal to university dot and here universal city dot name.
So we fetch all students and the university ordered them by their name and put their names in a new
object together with the names of their university.
So that's pretty much what we do with this line of code here and now.
What we can do, we can write that on to the console so we can just going to say something like new
collections.
Or actually it's a singular new collection and this will be for each and var in call calls standing
for collections in new collection.
So we're going to go through every single collection.
And what I want to print out now is CW Student Zero from University one
And now we need to call that student name and call that university name.
So we cut them off and now let's just print it out.
So see.
W So we're going to say student at the position zero, which means, well, we just want to have the
student name here from university which will be one, and the student name is called Dot Student Name
and the university name is called our university name.
So this pretty much does it.
It gives me that one collection aspect of my new collections, and it's going to give me or print that
out.
So it's going to print out the first student and the second student and so forth.
So all the students and their universities.
So let's call that method here at the top before doing this ordering thing.
So let me uncomment that.
Now, let's go ahead and call this method student and university name collection.
Now let's run it.
And we are so new collection student Carla from University, Yale student Frank from University, Beijing
and so forth.
So you see all of those guys and ladies and all of their universities and they're ordered by their name.
So.
C c f.
J l t.
All right.
So now you see how you can create new collections based on collections that you had already.
So what we simply do here is we loop through all students and we join that with a university.
So it's pretty much the same thing that we've done here with all students from that uni.
Then we order them by name and then we select.
And now instead of selecting the student, we select a completely new collection.
We just say, okay, I want that to happen for every single student.
So I want this combination of student name and university name for every single student.
And now we have this new collection, which is pretty much a list.
So it's a new enumerable and you list of students which contains now all of our students with the university
name.
So it doesn't have any additional information.
It only has the student name and the university name.
It doesn't know about the ID, doesn't know about all those kind of things, and only knows those two
things, which is name and university name where student name and university name and well, we use
that to print it out here so we could store that in a different table if we would use as SQL here,
and we will do so later on.
But that's something that we first of all needed to check out.
So we first needed to understand what's going on with Lync and what it can do even without using SQL.
And you already see the advantage.
You can use that with collections of different types in C-sharp.
You can use that with XML and you can use it with SQL.
So you're not limited to one data source, which is pretty awesome because in the past you had to create
all of those different adapters which did all the job.
So that's it for this video.
In the next video we're going to do some more sick link stuff.
So see you there.