Hello friends, welcome to the next lab. In this lab, we will create one controller for child collection. Now, I'm going here and add one class. Subject, controller and which is controller I need to add the namespace is core MVC. Now I create one method public action result good now point to remember which method you are in here. If we get only the subject collection, then there is a no.
What's the use of that? Because the subject exists with students. Okay. So we can add here APA slash, we can add subject. Or we can add student now here to decide what you want, but as my perspective, we can add students here okay? Students now well to get that collection, which collection, subject collection followed purpose will help to pass on which student you want to for which student you want to access that subject collection.
Now here was student ID it's in parameter and here is TTP gate. And we have to add here, the perimeter. What is perimeter? Students Now here first, we check here is that student is in our collection or not. So for that purpose, we use red stood is equal to student context dot dot student list. First, before what Id is equal to student ID if a student is not found the same Oh But if a student is found in that case you need to return Okay.
Okay. In this we also want to check it our subject collection is present or not. So for that purpose we use subject collection to learn convicts couldn't not Student lists where you can have student ID, student ID, first default ad is equal to equal to student ID dot subject. Then what we get is the collection. Now, we check here subject collection.com If count is greater than zero, then only say that subject collection is you can return the result or not okay. Now, we have to access this particular model that purpose we have to add here okay and after that I will run this program and I protect debugger point here So, we will see Is the request coming here or not?
Absolutely. And if I pass full length, subjects or something, what it is subject something and if I send this request what we get? We can wait for. Okay? Our debugger come here, student IDs for now. I press f1 and the result becomes four not four.
Why this is happening. Again I send a request. It is cheap with a student. Whoo this on next is that no? No. Foley's Okay.
Then it comes here into the subject collection no condition so counted zero. That's why it sent me the reason not for now, I hope to see one Okay. Now IDs and what you can see we there is a collection of subjects which is internal collection So that's all about child collection. Thank you for watching. We'll see in the next lecture