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)

Which code segment should you insert at line 05?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server database and contains a LINQ to SQL data model. The
data model contains a function named createCustomer that calls a stored procedure. The stored
procedure is also named createCustomer. The createCustomer function has the following signature.
createCustomer (Guid customerID, String customerName, String address1)
The application contains the following code segment. (Line numbers are included for reference
only.)
01 CustomDataContext context = new CustomDataContext();
02 Guid userID = Guid.NewGuid();
03 String address1 = “1 Main Steet”;
04 String name = “Marc”;
05
You need to use the createCustomer stored procedure to add a customer to the database. Which
code segment should you insert at line 05?

You need to ensure that the application meets the following requirements: • Load only new customer records e

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You
use a TableAdapter object to load a DataTable object. The DataTable object is used as the data
source for a GridView control to display a table of customer information on a Web page. You need to
ensure that the application meets the following requirements:
• Load only new customer records each time the page refreshes.
• Preserve existing customer records.
What should you do?

Which IsolationLevel should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application
that connects to a Microsoft SQL Server 2008 database. The application performs a database query
within a transaction. You need to ensure that the application can read data that has not yet been
committed by other transactions. Which IsolationLevel should you use?

You need to retrieve the identity of the new record

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You
create a stored procedure to insert a new record in the Categories table according to following code
segment.
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. (Line numbers are included for reference only).
01 private static void ReturnIdentity(string connectionString)
02 {
03 using (SqlConnection connection = new SqlConnection(connectionString))
04 {
05 SqlDataAdapter adapter = new SqlDataAdapter(

06 “SELECT CategoryID, CategoryName FROM dbo.Categories”,connection);
07 adapter.InsertCommand = new SqlCommand(“InsertCategory”, connection);
08 adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
09 SqlParameter rowcountParameter = adapter.InsertCommand.Parameters.Add(
10 “@RowCount”, SqlDbType.Int);
11
12 adapter.InsertCommand.Parameters.Add(
13 “@CategoryName”, SqlDbType.NChar, 15, “CategoryName”);
14 SqlParameter identityParameter = adapter.InsertCommand.Parameters.Add(
15 “@Identity”, SqlDbType.Int, 0, “CategoryID”);
16
17 DataTable categories = new DataTable();
18 adapter.Fill(categories);
19 DataRow categoryRow = categories.NewRow();
20 categoryRow[“CategoryName”] = “New Beverages”;
21 categories.Rows.Add(categoryRow);
22 adapter.Update(categories);
23 Int32 rowCount = (Int32)adapter.InsertCommand.Parameters[“@RowCount”].Value;
24 }
25 }
You need to retrieve the identity of the new record. You also need to retrieve the row count. What
should you do?

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

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application.
You use the ADO.NET Entity Framework Designer to model entities. The application includes selftracking entities as shown in the following diagram.

There is a Person entity named person1 that has Track Changes turned on. You need to delete all email addresses that are associated with person1 by using an ObjectContext named context. What
are two possible code segments that you can use to achieve this goal? (Each correct answer presents
a complete solution. Choose two).

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 ADO.NET Entity Framework to
manage persistence-ignorant entities. You create an ObjectContext instance named context. Then,
you directly modify properties on several entities. You need to save the modified entity values to the
database. Which code segment should you use?

Which code segment should you insert at line 06?

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 has two DataTable objects
that reference the Customers and Orders tables in the database. The application contains the
following code segment. (Line numbers are included for reference only.)
01 DataSet customerOrders = new DataSet();
02 customerOrders.EnforceConstraints = true;
03 ForeignKeyConstraint ordersFK = new ForeignKeyConstraint(“ordersFK”,
04 customerOrders.Tables[“Customers”].Columns[“CustomerID”],
05 customerOrders.Tables[“Orders”].Columns[“CustomerID”]);
06
07 customerOrders.Tables[“Orders”].Constraints.Add(ordersFK);
You need to ensure that an exception is thrown when you attempt to delete Customer records that
have related Order records. Which code segment should you insert at line 06?

You need to ensure that the function verifies that customers have no outstanding orders before they are marked

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 application uses DataContexts to
query the database. You create a function that meets the following requirements:
• Updates the Customer table on the database when a customer is marked as deleted. • Updates the
related entries in other tables (CustomerAddress, CustomerContacts) by marking them as deleted.
• Prevents consumer code from setting the Deleted columns value directly.
You need to ensure that the function verifies that customers have no outstanding orders before they
are marked as deleted. You also need to ensure that existing applications can use the updated
function without requiring changes in the code. What should you do?


Page 2 of 3112345...102030...Last »