Welcome to TestSimulate

Pass Your Next Certification Exam Fast!

Everything you need to prepare, learn & pass your certification exam easily.

365 days free updates. First attempt guaranteed success.

Microsoft TS: Accessing Data with Microsoft .NET Framework 4 (070-516) Free Practice Test

Question 1
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application connects to two different Microsoft SQL Server 2008 database servers named Server1 and
Server2.
A string named sql1 contains a connection string to Server1. A string named sql2 contains a connection
string to Server2.
01 using (TransactionScope scope = new
02 ...
03 )
04 {
05 using (SqlConnection cn1 = new SqlConnection(sql1))
06 {
07 try{
08 ...
09 }
10 catch (Exception ex)
11 {
12 }
13 }
14 scope.Complete();
15 }
You need to ensure that the application meets the following requirements:
-There is a SqlConnection named cn2 that uses sql2.
-The commands that use cn1 are initially enlisted as a lightweight transaction.
The cn2 SqlConnection is enlisted in the same TransactionScope only if commands executed by cn1 do not
throw an exception.
What should you do?

Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 2
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create a Windows
Communication Foundation (WCF) Data Services service.
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 }
You need to ensure that the correct authentication header is present when requests are made by using
MyDataServiceContext.
What should you do?

Correct Answer: C
Question 3
You are adding a process to the application. The process performs the following actions:
1.Opens a ContosoEntities context object named context1.
2.Loads a Part object into a variable named part1.
3.Calls the Dispose() method on context1.
4.Updates the data in part1.
5.Updates the database by using a new ContosoEntities context object named context2.
You need to update the database with the changed data from part1. What should you do?

Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 4
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server database.
The application uses the following object query to load a product from the database.
(Line numbers are included for reference only.)
01 using (AdventureWorksEntities advWorksContext = new AdventureWorksEntities
())
02 {
03 ObjectQuery <Product> productQuery = advWorksContext.Product.Where
("it.ProductID = 900");
04 ...
05 }
You need to log the command that the query executes against the data source. Which code segment should you insert at line 04?

Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 5
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application.
You use the ADO.NET Entity Framework Designer to model entities. You retrieve an entity from an object context.
A different application updates the database. You need to update the entity instance to reflect updated
values in the database.
Which line of code should you use?

Correct Answer: C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 6
You are developing a new feature in the application to display a list of all bundled products.
You need to write a LINQ query that will return a list of all bundled products. Which query expression should
you use?

Correct Answer: A
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 7
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that
connects to a Microsoft SQL Server 2008 database.
You use the ADO.NET Entity Framework Designer to model entities. You add the following stored
procedure to the database, and you add a function import to the model.
CREATE PROCEDURE [dbo].[InsertDepartment] @Name nvarchar(50), @ID int NULL OUTPUT
AS INSERT INTO Department (Name) VALUES (@Name) SELECT @ID = SCOPE_IDENTITY()
You need to insert a new department and display the generated ID. Which code segment should you use?

Correct Answer: A
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 8
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 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:

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.)

Correct Answer: A,D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 9
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 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 {
03 ObjectQuery <SalesOrderHeader> orders = 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?

Correct Answer: A
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 10
The database contains orphaned Color records that are no longer connected to Part records.
You need to clean up the orphaned records. You have an existing ContosoEntities context object named
context.
Which code segment should you use?

Correct Answer: C
Question 11
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application uses the ADO.NET Entity Framework to model entities.
The application allows users to make changes to entities while disconnected from the central data store.
You need to ensure that when the user connects to the central data store and retrieves new data, the application meets the following requirements:
-Changes made to the local data store in disconnected mode are preserved.
-Entities that have already been loaded into the local data store, but have not been modified by the user,
are updated with the latest data. What should you do?

Correct Answer: A
Question 12
The database contains a table named Categories. The Categories table has a primary key identity column
named CategoryID.
The application inserts new records by using the following stored procedure.
CREATE PROCEDURE dbo.InsertCategory @CategoryName nvarchar(15), @Identity int OUT
AS INSERT INTO Categories (CategoryName) VALUES(@CategoryName) SET @Identity = SCOPE_IDENTITY() RETURN @@ROWCOUNT
You write the following code segment.
SqlDataAdapter adapter = new SqlDataAdapter("SELECT categoryID, CategoryName
FROM dbo.Categories",connection);
adapter.InsertCommand = new SqlCommand("dbo.InsertCategory", connection);
adapter.InsertCommand.CommandType = commandType.StoredProcedure;
adapter.InsertCommand.Parameters.Add(new SqlParameter("@CategoryName",
SqlDbType.NVarChar, 15,"CategoryName"));
You need to retrieve the identity value for the newly created record. Which code segment should you add?

Correct Answer: D