70-516 · Question #189
You use Microsoft Visual Studio 2010 and Microsoft Entity Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. You use the ADO.NET LINQ to SQL model…
The correct answer is B. using (NorthwindDataContext dc = new NorthwindDataContext()) {. DataLoadOptions Class Provides for immediate loading and filtering of related data. DataLoadOptions.LoadWith(LambdaExpression) Retrieves specified data related to the main target by using a lambda expression. You can retrieve many objects in one query by using LoadWith…
Question
You use Microsoft Visual Studio 2010 and Microsoft Entity Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. You use the ADO.NET LINQ to SQL model to retrieve data from the database. The applications contains the Category and Product entities as shown in the following exhibit:
You need to ensure that LINO to SQL executes only a single SQL statement against the database. You also need to ensure that the query returns the list of categories and the list of products. Which code segment should you use?
Exhibit
Options
- Ausing (NorthwindDataContext dc = new NorthwindDataContext()) {
- Busing (NorthwindDataContext dc = new NorthwindDataContext()) {
- Cusing (NorthwindDataContext dc = new NorthwindDataContext()) {
- Dusing (NorthwindDataContext dc = new NorthwindDataContext()) {
How the community answered
(36 responses)- A6% (2)
- B75% (27)
- C17% (6)
- D3% (1)
Explanation
DataLoadOptions Class Provides for immediate loading and filtering of related data. DataLoadOptions.LoadWith(LambdaExpression) Retrieves specified data related to the main target by using a lambda expression. You can retrieve many objects in one query by using LoadWith. DataLoadOptions.AssociateWith(LambdaExpression) Filters the objects retrieved for a particular relationship. Use the AssociateWith method to specify sub-queries to limit the amount of retrieved data. DataLoadOptions Class How to: Retrieve Many Objects At Once (LINQ to SQL) How to: Filter Related Data (LINQ to SQL)
Topics
Community Discussion
No community discussion yet for this question.
