You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application uses the ADO.NET Entity Framework to model entities. You define a Category class by
writing the following code segment. (Line numbers are included for reference only.)
01 public class Category
02 {
03 public int CategoryID { get; set; }
04 public string CategoryName { get; set; }
05 public string Description { get; set; }
06 public byte[] Picture { get; set; }
07
08 }
You need to add a collection named Products to the Category class. You also need to ensure that the
collection supports deferred loading. Which code segment should you insert at line 07?
A.
public static List <Product> Products { get; set; }
B.
public virtual List <Product> Products { get; set; }
C.
public abstract List <Product> Products { get; set; }
D.
protected List <Product> Products { get; set; }
Explanation:
One of the requirements for lazy loading proxy creation is that the navigation properties must be
declared virtual (Overridable in Visual Basic).
If you want to disable lazy loading for only some navigation properties, then make those properties
non-virtual.
Loading Related Objects (Entity Framework)
(http://msdn.microsoft.com/en-us/library/gg715120(v=vs.103).aspx)