You need to ensure that the Product data for each Category object is lazy-loaded

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows
Communication Foundation (WCF) Data Services service. You deploy the data service to the
following URL: http://contoso.com/Northwind.svc.
You add the following code segment. (Line numbers are included for reference only.)
01 Dim uri As var = New Uri(“http://contoso.com/Northwind.svc/”)
02 Dim ctx As var = New NorthwindEntities(uri)
03 Dim categories As var = From c In ctx.Categories _
04 Select c

05 For Each c ategory As var In categories
06 PrintCategory(category)
07
08 For Each product As var In category.Products
09
10 PrintProduct(product)
11 Next
12 Next
You need to ensure that the Product data for each Category object is lazy-loaded. What should you
do?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows
Communication Foundation (WCF) Data Services service. You deploy the data service to the
following URL: http://contoso.com/Northwind.svc.
You add the following code segment. (Line numbers are included for reference only.)
01 Dim uri As var = New Uri(“http://contoso.com/Northwind.svc/”)
02 Dim ctx As var = New NorthwindEntities(uri)
03 Dim categories As var = From c In ctx.Categories _
04 Select c

05 For Each c ategory As var In categories
06 PrintCategory(category)
07
08 For Each product As var In category.Products
09
10 PrintProduct(product)
11 Next
12 Next
You need to ensure that the Product data for each Category object is lazy-loaded. What should you
do?

A.
Add the following code segment at line 07.
ctx.LoadProperty(category, “Products”)

B.
Add the following code segment at line 09.
ctx.LoadProperty(product, “*”)

C.
Add the following code segment at line 07.
Dim strPrdUri As var = String.Format(“Categories({0})?$expand=Products”, category.CategoryID)
Dim productUri As var = New Uri(strPrdUri, UriKind.Relative)
ctx.Execute(Of Pr oduct)(productUri)

D.
Add the following code segment at line 09.
Dim strPrdUri As var = String.Format(“Products?$filter=CategoryID eq {0}”, category.CategoryID)
Dim productUri As var = New Uri(strPrdUri, UriKind.Relative)
ctx.Execute(Of Product)(productUri)

Explanation:
LoadProperty(Object, String) Explicitly loads an object related to the supplied object by the specified
navigation property and using the default merge option.
UriKind Enumeration
(http://msdn.microsoft.com/en-us/library/system.urikind.aspx)
RelativeOrAbsolute The kind of the Uri is indeterminate.
Absolute The Uri is an absolute Uri.
Relative The Uri is a relative Uri.



Leave a Reply 0

Your email address will not be published. Required fields are marked *