PrepAway - Latest Free Exam Questions & Answers

Tag: Exam 70-516 (update October 26th, 2015)

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?

You need to ensure that the correct authentication header is present when requests are made by using MyDataSer

You use Microsoft .NET Framework 4 to develop an application that uses WCF Data Services to
retrieve entities. WCF Data Services uses an authentication scheme that requires an HTTP request
that has the following header format.
GET /OData.svc/Products(1)
Authorization: WRAP access_token=”123456789″
The application includes the following code. (Line numbers are included for reference only.)
01 public class Program
02 {
03 public void GetProducts()

04 {
05 var proxy = new MyDataServiceContext();
06
07 …
08 }
09
10 }
You need to ensure that the correct authentication header is present when requests are made by
using MyDataServiceContext. What should you do?

You need to update the conceptual model for the application on the production server

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. You deploy an application to a
production server. The application uses the model and mapping files that are deployed as
application resources. You need to update the conceptual model for the application on the
production server. What should you do?

Which code segment should you insert at line 11?

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. The application connects to a Microsoft SQL
Server database named AdventureWorks. The application includes the following code segment. (Line
numbers are included for reference only.)
01 using (AdventureWorksEntities context = new AdventureWorksEntities()){
02 ObjectQuery<SalesOrderHeader> orders =
03 context.SalesOrderHeader.Where(“it.CreditCardApprovalCode IS NULL”).Top(“100”);
04 foreach (SalesOrderHeader order in orders){
05 order.Status = 4;
06 }
07 try {
08 context.SaveChanges();
09 }
10 catch (OptimisticConcurrencyException){
11
12 }
13 }
You need to resolve any concurrency conflict that can occur. You also need to ensure that local
changes are persisted to the database. Which code segment should you insert at line 11?

Which code segment should you use?

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 2008 database. The application contains the following code segment.
string SQL = string.Format (“SELECT * FROM Customer WHERE CompanyName LIKE ‘%{0}%'”,
companyName);
var cmd = new SqlCommand(SQL, con);
You need to reduce the vulnerability to SQL injection attacks. Which code segment should you use?

Which code segment should you insert at line 11?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You
create a Data Access Layer (DAL) that is database-independent. The DAL includes the following code
segment. (Line numbers are included for reference only.)
01 static void ExecuteDbCommand(DbConnection connection)
02 {
03 if (connection != null){
04 using (connection){
05 try{
06 connection.Open();
07 DbCommand command = connection.CreateCommand();
08 command.CommandText = “INSERT INTO Categories (CategoryName) VALUES (‘Low Carb’)”;
09 command.ExecuteNonQuery();
10 }
11
12 catch (Exception ex){
13 Trace.WriteLine(“Exception.Message: ” + ex.Message);
14 }
15 }
16 }
17 }
You need to log information about any error that occurs during data access. You also need to log the
data provider that accesses the database. Which code segment should you insert at line 11?

What are two possible code segments that you can use to achieve this goal?

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL
Server 2008 database. You add the following stored procedure to the database.
CREATE PROCEDURE GetProducts
AS
BEGIN
SELECT ProductID, Name, Price, Cost
FROM Product
END
You create a SqlDataAdapter named adapter to execute the stored procedure. You need to fill a
DataTable instance with the first 10 rows of the result set. What are two possible code segments
that you can use to achieve this goal? (Each correct answer presents a complete solution. Choose
two.)


Page 3 of 3112345...102030...Last »