1 00:00:00,630 --> 00:00:05,990 ‫All right, so now let's get all students from a specific university. 2 00:00:06,000 --> 00:00:11,220 ‫So let's create a new method, because we have seen multiple methods already to get data, to change 3 00:00:11,220 --> 00:00:13,950 ‫data, to set up data, to combine data. 4 00:00:13,950 --> 00:00:16,020 ‫And now let's just search for data. 5 00:00:16,020 --> 00:00:24,960 ‫So let's create a method called get all students from Yale, and you can try to build that or implement 6 00:00:24,960 --> 00:00:26,220 ‫that method yourself. 7 00:00:27,000 --> 00:00:29,280 ‫So pause the video if you feel like it. 8 00:00:29,370 --> 00:00:29,790 ‫All right. 9 00:00:29,790 --> 00:00:36,990 ‫So I'm creating a new variable called Students from Yale, and that will end up being a collection of 10 00:00:36,990 --> 00:00:44,280 ‫innumerable and from student in data context dot students. 11 00:00:45,840 --> 00:00:58,560 ‫I want to check where the student dot university dot name is equal to Yale and I want to select that 12 00:00:58,560 --> 00:00:59,280 ‫student. 13 00:00:59,670 --> 00:01:01,830 ‫So that's nothing too new. 14 00:01:01,860 --> 00:01:08,040 ‫The only thing that is different is that we had this in data context students and students at university 15 00:01:08,310 --> 00:01:13,620 ‫name that is slightly different to what we have seen so far, but that's pretty cool because now we 16 00:01:13,620 --> 00:01:21,300 ‫get a list of all the students who are at the University of Yale and with just this one line, well, 17 00:01:21,300 --> 00:01:23,640 ‫it's actually one line, but in this case, it's three lines. 18 00:01:23,940 --> 00:01:24,480 ‫All right. 19 00:01:24,480 --> 00:01:30,810 ‫So now if we want to set that as the item source, we can just set that up. 20 00:01:30,810 --> 00:01:34,530 ‫Item source will be students from Yale. 21 00:01:35,610 --> 00:01:37,530 ‫Now let's check out that method. 22 00:01:37,620 --> 00:01:43,770 ‫Let's run it in our main method here, our main window constructor. 23 00:01:43,770 --> 00:01:48,720 ‫And here it's get all students from Yale. 24 00:01:50,250 --> 00:01:53,550 ‫All right, now let's see what is displayed to us. 25 00:01:55,220 --> 00:01:57,560 ‫And we are the only two students. 26 00:01:57,560 --> 00:02:01,510 ‫It's Carla and Toni, because the other ones are at another university. 27 00:02:01,520 --> 00:02:04,100 ‫They are at the Beijing Tech University. 28 00:02:04,100 --> 00:02:04,580 ‫Right. 29 00:02:04,910 --> 00:02:05,300 ‫All right. 30 00:02:05,300 --> 00:02:05,960 ‫So there you are. 31 00:02:05,990 --> 00:02:11,540 ‫You see the ID, the name, the gender and the university ID, then student lecturers and university 32 00:02:11,540 --> 00:02:13,660 ‫as well, who are or which are empty. 33 00:02:13,670 --> 00:02:17,360 ‫But that's based on all of the other stuff that we have run. 34 00:02:17,870 --> 00:02:18,200 ‫All right. 35 00:02:18,200 --> 00:02:20,390 ‫So that's how you can get all students from Yale. 36 00:02:20,420 --> 00:02:20,750 ‫All right. 37 00:02:20,750 --> 00:02:32,090 ‫And now let's go ahead and create a new method, public void, get all universities with transgenders. 38 00:02:32,090 --> 00:02:40,190 ‫So let's say there is in whatever country there is a support for universities who will have transgenders 39 00:02:40,190 --> 00:02:43,730 ‫and then to get additional funds or something like that. 40 00:02:43,730 --> 00:02:49,850 ‫Then you would run this method and it will give you all the students who are transgender and will give 41 00:02:49,850 --> 00:02:52,820 ‫you even all the universities who have transgenders. 42 00:02:52,820 --> 00:02:55,820 ‫So that's the actual return that we get here. 43 00:02:55,820 --> 00:02:58,190 ‫So let's create a new variable here. 44 00:02:58,190 --> 00:03:06,980 ‫Trans gender universities who are from student in data context students. 45 00:03:06,980 --> 00:03:13,010 ‫So we want to have students first of all, but then we want to join them. 46 00:03:13,010 --> 00:03:15,680 ‫So we want to join university. 47 00:03:16,930 --> 00:03:19,810 ‫And here university 48 00:03:22,510 --> 00:03:25,930 ‫in and this one is an on capital one. 49 00:03:26,320 --> 00:03:39,100 ‫So I create a new value here, join university in data context universities and I apply that on student 50 00:03:39,550 --> 00:03:40,720 ‫university. 51 00:03:41,620 --> 00:03:49,900 ‫So here I join two tables with each other and then I check where the university, and then I check university 52 00:03:49,900 --> 00:03:51,540 ‫because here we're joining it right now. 53 00:03:51,540 --> 00:04:02,590 ‫I can go ahead and choose that and I can check where the student the gender is equal to transgender. 54 00:04:04,210 --> 00:04:05,740 ‫And I want to select. 55 00:04:05,740 --> 00:04:06,970 ‫And what do I want to select? 56 00:04:06,970 --> 00:04:09,190 ‫Well, I don't want to select the student this time. 57 00:04:09,190 --> 00:04:11,650 ‫I want to select the university this time. 58 00:04:12,670 --> 00:04:13,330 ‫All right. 59 00:04:13,720 --> 00:04:15,550 ‫So now. 60 00:04:17,310 --> 00:04:23,430 ‫I need to use a double exclamation equals sign because I'm comparing and not setting a value. 61 00:04:23,430 --> 00:04:27,030 ‫And now just to make sure that the trend gender is written correctly. 62 00:04:27,030 --> 00:04:27,360 ‫All right. 63 00:04:27,360 --> 00:04:28,410 ‫It seems correct. 64 00:04:28,680 --> 00:04:30,870 ‫So that's how I wrote it. 65 00:04:30,870 --> 00:04:35,100 ‫And now I can show that on my data grid. 66 00:04:35,100 --> 00:04:40,710 ‫So items source is going to be transgender universities. 67 00:04:42,220 --> 00:04:42,790 ‫All right. 68 00:04:42,790 --> 00:04:49,870 ‫So if we call that method here, get all universities with transgenders. 69 00:04:49,870 --> 00:04:57,340 ‫And if you run that, we see that only Beijing Tech has transgender students. 70 00:04:57,400 --> 00:04:58,030 ‫All right. 71 00:04:58,030 --> 00:05:02,920 ‫So that's how you can generally join tables and play around with them. 72 00:05:02,920 --> 00:05:06,640 ‫And yeah, you see, it's done with C-sharp. 73 00:05:06,640 --> 00:05:08,380 ‫Everything is done with C-sharp here. 74 00:05:08,380 --> 00:05:16,150 ‫And no SQL or SQL code that we have to write manually now was a little challenge for you. 75 00:05:16,570 --> 00:05:22,030 ‫We want to have all the lectures which are taught at Beijing Tech. 76 00:05:24,840 --> 00:05:25,100 ‫Okay. 77 00:05:25,140 --> 00:05:25,860 ‫I hope you tried it. 78 00:05:25,860 --> 00:05:27,780 ‫That one is also pretty tough. 79 00:05:27,900 --> 00:05:36,450 ‫So if you manage to do that great job, get all lectures from Beijing Tech. 80 00:05:38,580 --> 00:05:39,270 ‫Now let's see. 81 00:05:39,300 --> 00:05:40,380 ‫What do we need? 82 00:05:41,070 --> 00:05:47,910 ‫Well, we need a variable called lectures from Beijing Tech. 83 00:05:48,690 --> 00:05:51,540 ‫And I check from my. 84 00:05:52,830 --> 00:05:57,930 ‫Student lectures in data context student lectures. 85 00:05:58,560 --> 00:06:15,030 ‫I join student that and in the data context of student on to my sl dot student ID which equals the student 86 00:06:15,030 --> 00:06:15,900 ‫ID 87 00:06:18,240 --> 00:06:26,550 ‫where my student dot university name is equal to Beijing Tech. 88 00:06:27,930 --> 00:06:29,640 ‫So plenty of thinking here. 89 00:06:29,640 --> 00:06:30,630 ‫That's really a tough one. 90 00:06:30,630 --> 00:06:35,940 ‫So if you manage to do that, really, that's that's great because then you quite understood what we're 91 00:06:35,940 --> 00:06:36,900 ‫doing here, right? 92 00:06:37,260 --> 00:06:40,320 ‫So lecture as well, that lecture. 93 00:06:40,590 --> 00:06:43,050 ‫So generally, what are we doing? 94 00:06:43,830 --> 00:06:46,290 ‫And by the way, there are multiple ways to solve that. 95 00:06:46,440 --> 00:06:53,490 ‫It's best to maybe not solve that with one query, but in our case, we're just fine doing it. 96 00:06:53,490 --> 00:06:59,730 ‫All right, so we loop the relationship table between student and lecture and simply check if the associated 97 00:06:59,730 --> 00:07:01,710 ‫student is from Beijing Tech. 98 00:07:01,710 --> 00:07:05,730 ‫If yes, we select that Associated Lecture. 99 00:07:06,330 --> 00:07:06,660 ‫All right. 100 00:07:06,660 --> 00:07:09,570 ‫So this is, as I said, this is a more complex one. 101 00:07:09,570 --> 00:07:16,200 ‫And this is really just to show you that we can connect to tables that have quite a far distance from 102 00:07:16,200 --> 00:07:16,620 ‫each other. 103 00:07:16,620 --> 00:07:20,640 ‫And by far, I mean, they are not really that related to each other. 104 00:07:20,640 --> 00:07:26,460 ‫But we can still do this connection because what we are doing is we get all the lectures from a specific 105 00:07:26,460 --> 00:07:31,620 ‫university and if we check that here, this is lecture and this is university, and they are so far 106 00:07:31,620 --> 00:07:38,040 ‫away because university is only connected to student and lecture is only connected to student lecture, 107 00:07:38,040 --> 00:07:39,960 ‫but student lecture is connected to student. 108 00:07:39,960 --> 00:07:41,700 ‫And that's what we need to do here. 109 00:07:41,700 --> 00:07:47,250 ‫We need to join them in a way that we get all the information that is required. 110 00:07:47,250 --> 00:07:50,730 ‫So that's why this one is a rather tricky one. 111 00:07:50,910 --> 00:07:52,740 ‫And if you manage to do that, great. 112 00:07:52,740 --> 00:07:54,390 ‫And if you didn't, no worries. 113 00:07:55,080 --> 00:08:03,450 ‫Then in order to display those, we use it as the item source again, which will be lectures from Beijing 114 00:08:03,480 --> 00:08:04,080 ‫Tech. 115 00:08:04,080 --> 00:08:17,100 ‫Now let's call this method here, get lectures from Beijing Tech and now let's run the code. 116 00:08:17,880 --> 00:08:19,650 ‫And we are in Beijing Tech. 117 00:08:19,650 --> 00:08:22,140 ‫For some reason only history is taught. 118 00:08:22,410 --> 00:08:23,460 ‫And why is that? 119 00:08:23,460 --> 00:08:26,310 ‫So if we check it out what we have done so far. 120 00:08:26,310 --> 00:08:33,330 ‫So we have created Layla and who's female and Jane who are with transgender, and those two are at Beijing 121 00:08:33,360 --> 00:08:33,840 ‫Tech. 122 00:08:34,290 --> 00:08:38,550 ‫And the problem here is that Jane doesn't even have a lecture. 123 00:08:38,550 --> 00:08:43,470 ‫So we haven't assigned a lecture to Jane and we have only assigned a lecture to Leslie. 124 00:08:43,470 --> 00:08:47,850 ‫And if we check it out here lately, has the context. 125 00:08:48,780 --> 00:08:51,150 ‫It's somewhere here. 126 00:08:51,420 --> 00:08:52,770 ‫Leslie has only history. 127 00:08:52,770 --> 00:08:57,960 ‫So we have no student who learns or who has math as this lecture. 128 00:08:57,960 --> 00:09:04,500 ‫And that's why we don't have math at Tech University, which shouldn't happen. 129 00:09:04,500 --> 00:09:04,710 ‫Right? 130 00:09:04,710 --> 00:09:09,960 ‫So a tech university should definitely have math as their subject or as the lecture. 131 00:09:09,990 --> 00:09:10,410 ‫All right. 132 00:09:10,410 --> 00:09:13,140 ‫So now I'm just going to show you two more things. 133 00:09:13,140 --> 00:09:16,290 ‫And I think it's best if we do that in the next video. 134 00:09:16,290 --> 00:09:20,640 ‫So we will see how to update data and how to delete data. 135 00:09:20,640 --> 00:09:22,260 ‫So see you in the next video.