PrepAway - Latest Free Exam Questions & Answers

Which method should you use?

You create a Microsoft .NET Framework console application that uses a Representational State Transfer (REST) API to query a custom list named Products.

The application contains the following code segment.

AdventureWorksDataContext codc = new AdventureWorksDataContext(new Uri(“http://contoso/_vti_bin/listdata.svc”));
codc.Credentials = CredentialCache.DefaultCredentials;

You need to read all items in Products into an object.

Which method should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
codc.Products.All;

B.
codc.Products.AsQueryable;

C.
codc.Products.ElementAt;

D.
codc.Products.ToList;

Explanation:
MNEMONIC RULE: “read all items ToList”

Interacting with SharePoint 2010 lists using REST, ASP.NET and ADO.NET Data Services
http://extendtheenterprise.com/2010/11/03/using-sharepoint-2010-rest-apis-in-asp-net/

Enumerable.ToList<TSource> Method
http://msdn.microsoft.com/en-us/library/bb342261.aspx


Leave a Reply