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 application can add new Customer entities

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 application includes a
Customer entity along with a CustomerKey property of the Guid type as shown in the following
exhibit.

You discover that when the application adds a new instance of a Customer, calling the SaveChanges
method results in the following error message:
“Server generated keys are only supported for identity columns.”
You need to ensure that the application can add new Customer entities.
What should you do?

What should you add to the connection string?

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 2008 database by using SQL Server authentication.
The application contains the following connection string.
SERVER=DBSERVER-01; DATABASE=pubs; uid=sa; pwd=secret;

You need to ensure that the password value in the connection string property of a SqlConnection
object does not exist after the Open method is called. What should you add to the connection
string?

Which code segment should you insert at line 02?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You
use the ADO.NET Entity Framework to model entities.
You write the following code segment. (Line numbers are included for reference only.)
01 Dim context As New AdventureWorksEntities(“http://localhost:1234/AdventureWorks.svc”) 02
03 Dim q As var = From c In context.Customers _
04 Where c.City =”London” _
05 Order By c.CompanyName _
06 Select c
You need to ensure that the application meets the following requirements:
• Compares the current values of unmodified properties with values returned from the data source
• Marks the property as modified when the properties are not the same
Which code segment should you insert at line 02?

Which code segment should you insert at line 02?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server database. The application uses the ADO.NET Entity
Framework to model entities. The database includes objects based on the exhibit. (Click the Exhibit
button.)

The application includes the following code segment. (Line numbers are included for reference only.)
01 Using advWorksContext As New AdventureWorksEntities()
02
03 End Using
You need to retrieve a list of all Products from todays sales orders for a specified customer.
You also need to ensure that the application uses the minimum amount of memory when retrieving
the list. Which code segment should you insert at line 02?

You need to define the connection life cycle of the DataAccessLayer class

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application contains the following code segment. (Line numbers are included for reference only.)
01 Class DataAccessLayer
02 Private Shared connString As String
03
04 …
05 Public Shared Function GetDataTable(command As String) As DataTable
06
07 …
08 End Function
09 End Class
You need to define the connection life cycle of the DataAccessLayer class. You also need to ensure
that the application uses the minimum number of connections to the database. What should you
do?

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?

Which code segment should you insert at line 02?

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 Dim reader As SqlDataReader = command.ExecuteReader(
02
03 )
04 While reader.Read()
05 pubID = reader.GetString(0)
06 …
07 stream = New FileStream()
08 writer = New BinaryWriter(stream)
09 startIndex = 0
10 retval = reader.GetBytes(1, startIndex, outByte, 0, bufferSize)
11 …
12 While retval = bufferSize
13 End While
14 writer.Write(outByte, 0, DirectCast(retval, Integer) – 1)
15 writer.Flush()
16 writer.Close()
17 stream.Close()
18 End While
You need to ensure that the code supports streaming data from the ProductImages column.
Which code segment should you insert at line 02?

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?

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?


Page 23 of 31« First...10...2122232425...30...Last »