You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the ADO.NET
Entity Framework to model entities. You create an entity model as shown in the following diagram.
You need to ensure that all Person entities and their associated EmailAddresses are loaded. Which code segment should you use?
A.
var people = context.People.Include(“EmailAddresses”).ToList();
B.
var people = context.People.Except(new ObjectQuery<Person>(“Person.EmailAddresses”, context)).ToList();
C.
var people = context.People.Except(new ObjectQuery<Person>(“EmailAddresses”, context)).ToList();
D.
var people = context.People.Include(“Person.EmailAddresses”).ToList();
Explanation:
CHAPTER 6 ADO.NET Entity Framework
Lesson 1: What Is the ADO.NET Entity Framework?
Lazy Loading vs. Explicit Loading vs. Eager Loading (page 384)http://msdn.microsoft.com/en-us/library/bb896272.aspx
I attended the actual exam last week, and a very similar question to this came up, I highlight the difference:
‘You need to ensure that all Person entities are loaded, _but their associated EmailAddresses are NOT loaded_. Which code segement should you use?’
The answer B and C were definately these ones, but A and D were a bit different, I do not remember for those.
I recommend to think about the correct answer for this question too.
In that case the answer would be C. ‘Except’ instead of ‘Include’, but still ‘EmailAdresses’.