[Free] New Updated (October) Microsoft 70-516 Real Exam 131-140

Ensurepass

 

QUESTION 131

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 manage Plain Old CLR Objects (POCO) entities.

 

You create a new POCO class. You need to ensure that the class meets the following requirements:

 

clip_image002It can be used by an ObjectContext.

clip_image002[1]It is enabled for change-tracking proxies.

 

Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

 

A.

Modify each mapped property to contain sealed and protected accessors.

B.

Modify each mapped property to contain non-sealed, public, and virtual accessors.

C.

Configure the navigation property to return a type that implements the ICollection interface.

D.

Configure the navigation property to return a type that implements the IQueryable interface.

E.

Configure the navigation property to return a type that implements the IEntityWithRelationships interface.

 

Correct Answer: BC

Explanation:

CHAPTER 6 ADO.NET Entity Framework

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

Other POCO Considerations (page 412)

 

 

 

 

 

 

 

 

 

 

QUESTION 132

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 dbo.GetClassAndStudents

 

AS

 

BEGIN

 

SELECT * FROM dbo.Class

 

SELECT * FROM dbo.Student END

 

You create a SqIGonnection named conn that connects to the database.

 

You need to fill a DataSet from the result that is returned by the stored procedure. The first result set must be added to a DataTable named Class, and the second result set must be added to a DataTable named Student.

 

Which code segment should you use?

 

A.

DataSet ds = new DataSet();

SqlDataAdapter ad = new SqlDataAdapter

(“GetClassAndStudents”, conn);

ds.Tobies.Add(“Class”);

ds.Tables.Add(“Student”);

ad.Fill(ds);

B.

DataSet ds = new DataSet();

SqlDataAdapter ad = new SqlDataAdapter

(“GetClassAndStudents”, conn);

ad.TableMappings.Addf’Table”, “Class”);

ad.TableMappings.Add(“Tablel”, “Student”) ;

ad.Fill(ds) ;

C.

DataSet ds = new DataSet();

SqlDataAdapter ad = new SqlDataAdapter

(“GetClassAndStudents”, conn);

ad.MissingMappingAction = MissingMapplngAction.Ignore; ad.Fill(ds, “Class”);

ad.Fill(ds, “Student”);

D.

DataSet ds = new DataSet();

SqlDataAdapter ad = new SqlDataAdapter

(“GetClassAndStudents”, conn);

ad.Fill(ds);

 

Correct Answer: B

Explanation:

http://msdn.microsoft.com/en-us/library/ms810286.aspx

http://msdn.microsoft.com/en-us/library/ms810286.aspx

 

 

 

 

 

QUESTION 133

You use Microsoft Visual Studio 2010 and Microsoft NET Framework 4 to create an application. You use the ADONET Entity Data Model (EDM) to define a Customer entity.

 

You need to add a new Customer to the data store without setting all the customer’s properties.

< span lang="EN-US" style="font-family: ; mso-font-kerning: 0pt; mso-no-proof: yes"> 

What should you do?

 

A.

Call the Create method of the Customer object

B.

Call the CreateObject method of the Customer object

C.

Override the Create method for the Customer object

D.

Override the Save Changes method for the Customer object

 

Correct Answer: B

Explanation:

CreateObject<T> Creates and returns an instance of the requested type.

 

 

QUESTION 134

You use Microsoft .NET Framework 4 to develop an application that uses Entity Framework. The application includes the following Entity SQL (ESQL) query.

 

SELECT VALUE product

 

FROM AdventureHorksEntities.Products As product

 

ORDER BY product.ListPrice

 

You need to modify the query to support paging of the query results.

 

Which query should you use?

 

A.

SELECT TOP Stop VALUE product

FROM AdventureHorksEntities.Products AS product ORDER BY product.ListPrice SKIP @skip

B.

SELECT VALUE product

FROM AdventureHorksEntities.Products AS product ORDER BY product.ListPrice SKIP @skip LIMIT @limit

C.

SELECT SKIP @skip VALUE product

FROM AdventureHorksEntities.Products AS product ORDER BY product.ListPrice LIMIT @limit

D.

SELECT SKIP @skip TOP Stop VALUE product

FROM AdventureHorksEntities.Products AS product ORDER BY product.ListPrice

 

Correct Answer: B

Explanation:

Entity SQL Reference

http://msdn.microsoft.com/en-us/library/bb387118.aspx

How to: Page Through Query Results

http://msdn.microsoft.com/en-us/library/bb738702.aspx

 

 

 

 

 

 

 

QUESTION 135

You use Microsoft .NET Framework 4 to develop

an application that connects to a Microsoft SQL Server 2008 database. The application uses nested transaction scopes. An inner transaction scope contains code that inserts records into the database.

 

You need to ensure that the inner transaction can successfully commit even if the outer transaction rolls back.

 

What are two possible TransactionScope constructors that you can use for the inner transaction to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

 

A.

TransactionScope(TransactionScopeOption.Required)

B.

TransactionScope ()

C.

TransactionScope(TransactionScopeOption.RequiresNew)

D.

TransactionScope (TransactionScopeOption.Suppress)

 

Correct Answer: CD

Explanation:

Required – A transaction is required by the scope. It uses an ambient transaction if one already exists.

Otherwise, it creates a new transaction before entering the scope. This is the default value.

RequiresNew – A new transaction is always created for the scope.

Suppress – The ambient transaction context is suppressed when creating the scope.

All operations within the scope are done without an ambient transaction context.

TransactionScopeOption Numeration

http://msdn.microsoft.com/en-us/library/system.transactions.transactionscopeoption.aspx

 

 

QUESTION 136

DRAG DROP

You have a method named updateCustomers that updates a DataTable.

 

You need to develop a method that meets the following requirements:

 

Takes a DataTable as a parameter

 

Calls updateCustomers by using the DataTable

 

Returns false if updateCustomers updates one of the rows in the DataTable with a value that contains @ in the FirstName column.

 

What code should you use?

 

To answer, drag the appropriate elements to the correct locations. Each element may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

 

clip_image004

 

Correct Answer:

clip_image006

 

 

QUESTION 137

You use Microsoft .NET Framework 4 to develop an application that connects to two separate Microsoft SQL Server 2008 databases. The Customers database stores all the customer information, and the Orders database stores all the order information.

 

The application includes the following code. (Line numbers are included for reference only.)

 

01 try

 

02 {

 

03 conn.Open();

 

04 tran = conn.BeginTransaction(“Order”);

 

05 SqlCommand cmd = new SqlCommand();

 

06 cmd.Connection = conn;

 

07 cmd.Transaction = tran;

 

08 tran.Save(“save1”);

 

09 cmd.CommandText – “INSERT INTO [Cust].dbo.Customer ” +

 

“(Name, PhoneNumber) VALUES (‘Paul Jones’, ” + “‘404-555-1212’)”;

 

10 cmd.ExecuteNonQuery(); iltran.Save(“save2”);

 

11

 

12 cmd.CommandText = “INSERT INTO [Orders].dbo.Order ” +

 

“(CustomerID) VALUES (1234)”;

 

13 cmd.ExecuteNonQuery();

 

14 tran.Save(“save3”);

 

15 cmd.CommandText = “INSERT INTO [Orders] .dbo.” +

 

“OrderDetail (OrderlD, ProductNumber) VALUES” + “(5678, ‘DC-6721’)”;

 

16 cmd.ExecuteNonQuery();

 

17 tran.Commit();

 

18 }

 

19 catch (Exception exj

 

20 {

 

21

 

22 }

 

You run the program, and a timeout expired error occurs at line 16.

 

You need to ensure that the customer information is saved in the database. If an error occurs while the order is being saved, you must roll back all of the order information and save the customer information.

 

Which line of code should you insert at line 21?

 

A.

tran.Rollback ();

B.

tran.Rollback (“save2”); tran.Commit();

C.

tran.Rollback (); tran.Commit();

D.

tran.Rollback(“save2”);

 

Correct Answer: B

Explanation:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqltransaction.save.aspx

http://msdn.microsoft.com/en-us/library/4ws6y4dy.aspx

 

 

 

 

QUESTION 138

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 load records from the Customers table into a DataSet object named dataset.

 

You need to retrieve the value of the City field from the first and last records in the Customers table.

 

Which code segment should you use?

 

A.

DataTable dt = dataset.Tables[“Customers”];

string first = dt.Rows[0][“City”].ToString();

string last = dt.Rows[dt.Rows.Count – 1][“City”].ToString();

B.

DataTable dt = dataset.Tables[“Customers”];

string first = dt.Rows[0][“City”].ToString();

string last = dt.Rows[dt.Rows.Count][“City”].ToString();

C.

DataRelation relationFirst = dataset.Relations[0];

DataRelation relationLast = dataset.Relations[dataset.Relations.Count – 1];

string first = relationFirst.childTable.Columns[“City”].ToString();

string last = relationLast.childTable.Columns[“City”].ToString();

D.

DataRelation relationFirst = dataset.Relations[0];

DataRelation relationLast = dataset.Relations[dataset.Relations.Count];

string first = relationFirst.childTable.Columns[“City”].ToString();

string last = relationLast.childTable.Columns[“City”].ToString();

 

Correct Answer: A

 

 

QUESTION 139

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application that connects to a database by using the Entity Framework. You create an Entity Data Model (EDM) by using the Generate from database wizard for the following tables.

 

clip_image007

 

You need to ensure that the EDM contains an entity type named Employee that contains all of the data from both tables.

 

What should you do?

 

A.

Delete the EmployeeAccess entity, create a new property named CanAccessBuilding5 on the Employee entity, and add a mapping for the new property.

B.

Create an inheritance relationship between the Employee and EmployeeAccess entities, and use CanAccessBuildingS as an inheritance condition.

C.

Modify the .edmx file to include the following line of code. <NovigotionProperty Name=”Type” FromRole-“EmployeeAccess” ToRole-“Employee” />

D.

Create a one-to-one association named CanAccessBuildingsAssociation between the EmployeeAccess entity and the Employee entity.

 

Correct Answer: A

 

 

QUESTION 140

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 using model-first development.

 

The database has the following requirements:

 

clip_image002[2]Each table must have a datetime column named time_modified.

clip_image002[3]Each table requires a trigger that updates the value of the time_modified column when a row is inserted or updated.

 

You need to ensure that the database script that is created by using the Generate Database From Model option meets the requirements.

 

What should you do?

 

A.

Create a new T4 Template, and set the DDL Generation template to the name of the new template.

B.

Create a new Windows Workflow Foundation workflow, and set Database Generation Workflow to the name of the new workflow.

C.

Add a DateTime property named time_modified to each entity in the model, and set the property s StoreGeneratedPattern to Computed.

D.

Add a new entity named time_modified to the model, and modify each existing entity so that it inherits from the new entity.

 

Correct Answer: A

Explanation:

Model-First in the Entity Framework 4

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

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…