nerdexam
Microsoft

70-516 · Question #111

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application uses the ADO.NET Entity Framework to model entities. You define a Category class by…

The correct answer is B. public virtual List <Product> Products { get; set; }. 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…

Implementing Data Access

Question

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 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?

Options

  • Apublic static List <Product> Products { get; set; }
  • Bpublic virtual List <Product> Products { get; set; }
  • Cpublic abstract List <Product> Products { get; set; }
  • Dprotected List <Product> Products { get; set; }

How the community answered

(53 responses)
  • A
    15% (8)
  • B
    74% (39)
  • C
    8% (4)
  • D
    4% (2)

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)

Topics

#POCO#virtual property#lazy loading#Entity Framework

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice