PrepAway - Latest Free Exam Questions & Answers

Category: 70-516 (v.2)

Exam 70-516: TS: Accessing Data with Microsoft .NET Framework 4 (update October 26th, 2015)

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 var uri = new Uri(@”http://contoso.com/Northwind.svc/”);
02 var ctx = new NorthwindEntities(uri);
03 var categories = from c in ctx.Categories
04 select c;
05 foreach (var category in categories) {
06 PrintCategory(category);
07
08 foreach (var product in category.Products) {
09
10 PrintProduct(product);
11 }
12 }
You need to ensure that the Product data for each Category object is lazy-loaded. What should you
do?

Which code segment should you insert at line 14?

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. The conceptual schema definition
language (CSDL) file contains the following XML fragment.
< EntityType Name=”Contact”>

<Property Name=”EmailPhoneComplexProperty”
Type=”AdventureWorksModel.EmailPhone”
Nullable=”false” />
</EntityType>

<ComplexType Name=”EmailPhone”>
<Property Type=”String” Name=”EmailAddress”
MaxLength=”50″ FixedLength=”false”
Unicode=”true” />
<Property Type=”String” Name=”Phone” MaxLength=”25″
FixedLength=”false” Unicode=”true” />
</ComplexType>
You write the following code segment. (Line numbers are included for reference only.)
01 using (EntityConnection conn = new EntityConnection(“name=AdvWksEntities”))
02 {
03 conn.Open();
04 string esqlQuery = @”SELECT VALUE contacts FROM
05 AdvWksEntities.Contacts AS contacts
06 WHERE contacts.ContactID == 3″;
07 using (EntityCommand cmd = conn.CreateCommand())
08 {
09 cmd.CommandText = esqlQuery;
10 using (EntityDataReader rdr = cmd.ExecuteReader())
11 {
12 while (rdr.Read())
13 {
14
15 }
16 }
17 }
18 conn.Close();
19 }
You need to ensure that the code returns a reference to a ComplexType entity in the model named
EmailPhone. Which code segment should you insert at line 14?

What are two possible ways to achieve this goal?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server 2008 database. You create classes by using LINQ to
SQL based on the records shown in the exhibit. (Click the Exhibit button.)

You need to create a LINQ query to retrieve a list of objects that contains the OrderID and
CustomerID properties. You need to retrieve the total price amount of each Order record. What are
two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose
two.)

Which code segment should you insert at line 10?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server 2008 database. The database includes a database
table named ProductCatalog as shown in the exhibit. (Click the Exhibit button.)

You add the following code segment to query the first row of the ProductCatalog table. (Line
numbers are included for reference only.)
01 using (var cnx = new SqlConnection(connString))
02 {

03 var command = cnx.CreateCommand();
04 command.CommandType = CommandType.Text;
05 command.CommandText =”SELECT TOP 1 * FROM dbo.ProductCatalog”;
06 cnx.Open();
07 var reader = command.ExecuteReader();
08 if (reader.Read()) {
09 var id = reader.GetInt32(0);
10
11 reader.Close();
12 }
13 }
You need to read the values for the Weight, Price, and Status columns. Which code segment should
you insert at line 10?

Which code segment should you insert at line 03?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application retrieves data from a Microsoft SQL Server 2008 database named AdventureWorks. The
AdventureWorks.dbo.ProductDetails table contains a column named ProductImages that uses a
varbinary(max) data type. You write the following code segment. (Line numbers are included for
reference only.)
01 SqlDataReader reader =
02 command.ExecuteReader(
03
04 );
05 while (reader.Read())
06 {
07 pubID = reader.GetString(0);
08 stream = new FileStream(
09 …
10 );
11 writer = new BinaryWriter(stream);
12 startIndex = 0;

13 retval = reader.GetBytes(1, startIndex, outByte, 0, bufferSize);
14 while (retval == bufferSize)
15 {
16 …
17 }
18 writer.Write(outByte, 0, (int)retval – 1);
19 writer.Flush();
20 writer.Close();
21 stream.Close();
22 }
You need to ensure that the code supports streaming data from the ProductImages column. Which
code segment should you insert at line 03?

Which code segment should you insert at line 04?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application contains the following XML document.
<bib>
<book title=”TCP/IP Illustrated” year=”1994″>
<author> Author1 </author>
</book>
<book title=”Programming in Unix” year=”1992″>

<author> Author1 </author>
<author> Author2 </author>
<author> Author3 </author>
</book>
<book title=”Data on the Web” year=”2000″>
<author> Author4 </author>
<author> Author3 </author>
</book>
</bib>
You add the following code fragment. (Line numbers are included for reference only.)
01 public IEnumerable<XElement> GetBooks(string xml)
02 {
03 XDocument doc = XDocument.Parse(xml);
04
05 }
You need to return a list of book XML elements that are authored by Author1. Which code segment
should you insert at line 04?

Which code segment should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server database. You use the following SQL statement to
retrieve an instance of a DataSet object named ds:
SELECT CustomerID, CompanyName, ContactName, Address, City
FROM dbo.Customers
You need to query the DataSet object to retrieve only the rows where the ContactName field is not
NULL. Which code segment should you use?

You need to access the service by using a WCF Data Services client

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application
that will access a WCF data service. The solution contains the projects shown in the following table.

The WCF data service exposes an Entity Framework model. You need to access the service by using a
WCF Data Services client. What should you do in the Application.Client project?

You need to ensure that the entity that is mapped to the ContentTypeDerived table derives from the entity that

You use the Microsoft .NET Framework 4 Entity Framework to develop an application that contains
an Entity Data Model for the following database tables.

You need to ensure that the entity that is mapped to the ContentTypeDerived table derives from the
entity that is mapped to the ContentTypeBase table. What should you do?


Page 4 of 31« First...23456...102030...Last »