exam questions

Exam 70-487 All Questions

View all questions & answers for the 70-487 exam

Exam 70-487 topic 1 question 85 discussion

Actual exam question from Microsoft's 70-487
Question #: 85
Topic #: 1
[All 70-487 Questions]

DRAG DROP -
You have an application that uses an Entity Framework context. Lazy loading is disabled for the context. The application uses an Azure SQL Database named
Students.
You need to retrieve the courses of a student who has an ID of 100. The solution must use lazy loading.
Which five code blocks should you use? Develop the solution by selecting and arranging the required code blocks in the correct order.
You will not need all of the code blocks.
NOTE:
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
References:
http://www.entityframeworktutorial.net/Querying-with-EDM.aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
dosper
Highly Voted 5 years, 6 months ago
using (var context = new SchoolEntities()) { IList students = context.Students.ToList<Student>(); Student student = students.Where(s => s.StudentID == 100).FirstOrDefault(); context.Entry(student).Collection(s => s.Courses).Load(); foreach (var course in student.Courses) Console.WriteLine(course.CourseName); }
upvoted 62 times
tiger25
5 years, 4 months ago
Correct.
upvoted 3 times
...
Xenoi
4 years, 10 months ago
`context.Students.ToList()` retrieves all students from the DB before filtering... not very efficient. But it's the only answer that works.
upvoted 3 times
elathir
4 years, 9 months ago
I agree with Xenoi, only this will work, but it's against all good practicies.
upvoted 1 times
...
...
...
bobtables
Most Recent 5 years, 6 months ago
@MJKWandile - No, the answer is definitely wrong.
upvoted 3 times
...
MJKWandile
5 years, 7 months ago
I'm confused a bit, is it possible to still use context variable outside the using block?
upvoted 4 times
cpuellesc
5 years, 6 months ago
is not possible
upvoted 3 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...