[Free] New Updated (October) Microsoft 70-516 Real Exam 71-80

Ensurepass

 

 

QUESTION 71

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 AdventureWorks Entities context = new AdventureWorksEntities (

 

02 ” http://localhost:1234/AdventureWorks.svc “

 

03 );

 

04

 

05 var q = from c in context.Customers

 

06 where c.City == “London”

 

07 orderby c.CompanyName

 

08 select c;

 

You need to e

nsure that the application meets the following requirements:

 

clip_image002Compares the current values of unmodified properties with values returned from the data source.

clip_image002[1]Marks the property as modified when the properties are not the same.

 

Which code segment should you insert at line 04?

 

A.

context.MergeOption = MergeOption.AppendOnly;

B.

context.MergeOption = MergeOption.PreserveChanges;

C.

context.MergeOption = MergeOption.OverwriteChanges;

D.

context.MergeOption = MergeOption.NoTracking;

 

Correct Answer: B

Explanation:

PreserveChanges – Objects that do not exist in the object context are attached to the context.

If the state of the entity is Unchanged, the current and original values in the entry are overwritten with data source values.

The state of the entity remains Unchanged and no properties are marked as modified. If the state of the entity is Modified, the current values of modified properties are not overwritten with data source values.

The original values of unmodified properties are overwritten with the values from the data source.

In the .NET Framework version 4, the Entity Framework compares the current values of unmodified properties with the values that were returned from the data source. If the values are not the same, the property is marked as modified.

MergeOption Enumeration

http://msdn.microsoft.com/en-us/library/system.data.objects.mergeoption.aspx

 

 

 

 

 

 

QUESTION 72

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You create stored procedures by using the following signatures:

 

clip_image004

 

You create a Microsoft ADO.NET Entity Data Model (EDM) by using the Product and Order entities as shown in the exhibit. (Click the Exhibit button.)

 

clip_image005

 

You need to map the Product and Order entities to the stored procedures.

 

To which two procedures should you add the Qproductld parameter? (Each correct answer presents part of the solution. Choose two.)

 

A.

Order_Delete

B.

Product_Update

C.

Order_Update

D.

Product_Delete

 

Correct Answer: AC

Explanation:

@productId parameter resides in the order table…

 

 

QUESTION 73

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application. You use the Entity Framework Designer to create an Entity Data Model (EDM).

 

You need to create a database creation script for the EDM.

 

What should you do?

 

A.

Use a new Self-Tracking Entities template.

B.

Drag entities to Server Explorer.

C.

Run the Generate Database command.

D.

Select Run Custom Tool from the solution menu.

 

Correct Answer: C

Explanation:

You can generate the database from the conceptual model: Right-click the Entity Framework designer surface and then choose Generate Database From Model. The script has been created and saved to a file, but it has not been executed.

Model First

http://blogs.msdn.com/b/efdesign/archive/2008/09/10/model-first.aspx

 

 

QUESTION 74

You use Microsoft .NET Framework 4 to develop an application that uses the Entity Framework.

 

The application has an entity model with a Person entity. A Person instance named person1 and an ObjectContext instance named model exist.

 

You need to delete the person1 instance. Which code segment should you use?

 

A.

model.DeleteObject(person1);

model.SaveChanges();

B.

model.Detach(person1);

model.SaveChanges();

C.

model.ExecuteStoreCommand(“Delete”, new []

{ new ObjectParameter(“Person”, person1) });

model.SaveChanges();

D.

model.ExecuteFunction(“Detach”, new []

{ new ObjectParameter(“Person”, person1) });

model.SaveChanges();

 

Correct Answer: A

Explanation:

ObjectContext.DeleteObject Marks an object for deletion from the ObjectStateManager. The object is deleted in the data source when the SaveChanges method is called. ObjectContext.ExecuteStoreCommand Method executes an arbitrary command directly against the data source using the existing connection.

< font style="font-size: 10pt" color="#000000"> 

 

QUESTION 75

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 model contains an entity type named Product.

 

You need to ensure that a stored procedure will be invoked when the ObjectContext.SaveChanges method is executed after an attached Product has changed.

 

What should you do in the ADO.NET Entity Framework Designer?

 

A.

Add a new entity that has a base class of Product that is mapped to the stored procedure.

B.

Add a stored procedure mapping for the Product entity type.

C.

Add a complex type named Product that is mapped to the stored procedure.

D.

Add a function import for the Product entity type.

 

Correct Answer: B

Explanation:

The ObjectContext class exposes a SaveChanges method that triggers updates to the underlying database.

By default, these updates use SQL statements that are automatically generated, but the updates can use stored procedures that you specify. The good news is that the application code you use to create, update, and delete entities is the same whether or not you use stored procedures to update the database. To map stored procedures to entities, in the Entity Framework designer, right-click the entity and choose Stored Procedure Mapping.

In the Mapping Details window assign a stored procedure for insert, update, and delete.

 

CHAPTER 6 ADO.NET Entity Framework

Lesson 1: What Is the ADO.NET Entity Framework?

Mapping Stored Procedures(page 387-388)

 

Stored Procedures in the Entity Framework

http://msdn.microsoft.com/en-us/data/gg699321

 

 

QUESTION 76

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to several SQL Server databases.

 

You create a function that modifies customer records that are stored in multiple databases. All updates for a given record are performed in a single transaction.

 

You need to ensure that all transactions can be recovered.

 

What should you do?

 

A.

Call the RecoveryComplete method of the TransactionManager class.

B.

Call the EnlistDurable method of the Transaction class.

C.

Call the Reenlist method of the TransactionManager class.

D.

Call the EnlistVolatile method of the Transaction class.

 

Correct Answer: B

Explanation:

Volatile resource managers cannot recovery from failure to complete a transaction in which they were participating. To obtain a durable enlistment in a transaction, use the EnlistDurable method. For more information on volatile and durable resources, as well as how to enlist a resource, see Implementing A Resource Manager. For more information on how a resource manager responds to commit notification and prepare the commit, see Committing A Transaction In Single-Phase and Multi-Phase.

http://msdn.micros

oft.com/en-us/library/ms149779.aspx

 

 

QUESTION 77

You have a database named DB1 that contains a table named Customers.

 

You declare a DataSet named customersDataSet.

 

You need to ensure that customersDataSet contains all of the records from the Customers table.

 

Which code should you use?

 

clip_image007

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: A

Explanation:

* Example: To create a sample Visual C# .NET console application that demonstrates how to use the SqlCommandBuilder object to automatically generate the DeleteCommand, the InsertCommand, and the UpdateCommand properties of the SqlCommand object for a SqlDataAdapter object.

 

SqlConnection cn = new SqlConnection();

DataSet CustomersDataSet = new DataSet();

SqlDataAdapter da;

SqlCommandBuilder cmdBuilder;

 

//Set the connection string of the SqlConnection object to connect

//to the SQL Server database in which you created the sample //table.

cn.ConnectionString = “Server=server;Database=northwind;UID=login;PWD=password;”;

cn.Open();

//Initialize the SqlDataAdapter object by specifying a Select command

//that retrieves data from the sample table.

da = new SqlDataAdapter(“select * from CustTest order by CustId”, cn);

//Initialize the SqlCommandBuilder object to automatically generate and initialize

//the UpdateCommand, InsertCommand, and DeleteCommand properties of the SqlDataAdapter.

cmdBuilder = new SqlCommandBuilder(da);

//Populate the DataSet by running the Fill method of the SqlDataAdapter.

da.Fill(CustomersDataSet, “Customers”);

 

 

QUESTION 78

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 DataDefinition Language (DOL) script of the database contains the following code segment.

 

CREATE TABLE [Sales].[SalesOrderHeader](

 

[SalesOrdedD] [int] IDENTITY(1,1)NOT NULL,

 

(BillToAddressID][int] NOT NULL,

 

…CONSTRAINT [PK_SalesOrderHeader_SalesOrder1D]

 

PRIMARY KEY CLUSTERED ([SalesOrder1D]ASC)

 

)ALTER TABLE [Sales].[SalesOrderHeader]

 

WITH CHECK ADD CONSTRAINT [FK_SalesOrderHeader_Address]

 

FOREIGN KEY{[BilIToAddressID])

 

REFERENCES [Person] [Address](AddressID])

 

You create an ADO.NET Entity Framework model.

 

You need to ensure that the entities of the model correctly map to the DDL of the database.

 

What should your model contain?

 

A.

Exhibit A

B.

Exhibit B

C.

Exhibit C

D.

Exhibit D

 

Correct Answer: A

 

QUESTION 79

DRAG DROP

You use Microsoft .NET Framework 4 to create a data access layer component.

 

The component accesses data from a Microsoft SQL Server database named DB1. The component contains a class named Classl that represents data from a table in DB1 named Tablel. The following is the definition of Class1:

 

clip_image008

 

A database developer creates the following stored procedure to add entries to Table1:

 

clip_image009

 

You need to edit the Entity Data Model (EDM) for EDMCIassl to use the uspInsertTablel stored procedure to add data to the database.

 

What should you do? (Develop the solution by selecting and ordering the required code snippets. You may not need all of the code snippets.)

 

clip_image011

 

Correct Answer:

clip_image013

 

 

QUESTION 80

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?

 

A.

string SQL = “SELECT * FROM Customer WHERE ” + “CompanyName LIKE @companyName”;

var cmd = new Sql

Command(SQL, con);

cmd.Parameters.AddWithValue(“@companyName”,

string.Format(“%{0}%”, companyName));

B.

string SQL = “SELECT * FROM Customer WHERE ” + “CompanyName LIKE @companyName”;

var cmd = new SqlCommand(SQL, con);

var param = new SqlParameter(“@companyName”,

string.Format(“%{0}%”, companyName));

C.

string SQL = string.Format(“SELECT * FROM ” +

“Customer WHERE CompanyName LIKE {0}”,

new SqlParameter(“@companyName”,

string.Format(“%{0}%”, companyName)));

var cmd = new SqlCommand(SQL, con);

D.

string SQL = “SELECT * FROM Customer @companyName”;

var cmd = new SqlCommand(SQL, con);

cmd.Parameters.AddWithValue(“@companyName”,

string.Format(“WHERE CompanyName LIKE ‘%{0}%'”,

companyName));

 

Correct Answer: A

Explanation:

SqlParameterCollection.AddWithValue Method

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparametercollection.addwithvalue.aspx

Free VCE & PDF File for Microsoft 70-516 Real Exam

Instant Access to Free VCE Files: MCSE|MCSA|MCITP…
Instant Access to Free PDF Files: MCSE|MCSA|MCITP…