[Free] New Updated (October) Microsoft 70-516 Real Exam 141-150

Ensurepass

 

QUESTION 141

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. You use the ADO.NET Entity Framework to model your entities. You use ADO.NET selftracking entities.

 

You need to ensure that the change-tracking information for the selttracking entities can be used to update the database.

 

Which ObjectContext method should you call after changes are made to the entities?

 

A.

Attach

B.

Refresh

C.

SaveChanges

D.

ApplyChanges

 

Correct Answer: D

Explanation:

ApplyChanges takes the changes in a connected set of entities and applies them to an ObjectContext.

Starting with Microsoft Visual Studio 2010, the ADO.NET Self-Tracking Entity Generator template generates self-tracking entities.

This template item generates two .tt (text template) files: <model name>.tt and <model name>.Context.tt.

The <model name>.tt file generates the entity types and a helper class that contains the change-tracking logic that is used by self-tracking entities and the extension methods that allow setting state on self-tracking entities.

The <model name>.Context.tt file generates a typed ObjectContext and an extension class that contains ApplyChanges methods for the ObjectContext and ObjectSet classes. These methods examine the change-tracking information that is contained in the graph of self- tracking entities to infer the set of operations that must be performed to save the changes in the database.

Working with Self-Tracking Entities

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

 

 

QUESTION 142

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

 

clip_image001

 

You need to find out whether the object has a valid ObjectStateEntry instance.

 

Which code segment should you insert at line 05?

 

A.

if (this.EntityState != EntityState.Detached)

B.

if (this.EntityState != EntityState.Unchanged)

C.

if (this.EntityState != EntityState.Modified)

D.

if (this.EntityState != EntityState.Added)

 

Correct Answer: A

Explanation:

Detached The object exists but is not being tracked. An entity is in this state immediately after it has been created and before it is added to the object context. An entity is also in this state after it has been removed from the context by calling the Detach method or if it is loaded by using a NoTracking MergeOption. There is no ObjectStateEntry instance associated with objects in the Detached state.

Unchanged The object has not been modified since it was attached to the context or since the last time that the SaveChanges method was called. Added The object is new, has been added to the object context, and the SaveChanges method has not been called.

After the changes are saved, the object state changes to Unchanged. Objects in the Added state do not have original values in the ObjectStateEntry. Deleted The object has been deleted from the object context. After the changes are saved, th

e object state changes to Detached.

Modified One of the scalar properties on the object was modified and the SaveChanges method has not been called.

In POCO entities without change-tracking proxies, the state of the modified properties changes to Modified when the DetectChanges method is called. After the changes are saved, the object state changes to Unchanged.

 

EntityState Enumeration

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

 

CHAPTER 6 ADO.NET Entity Framework

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

Storing Information about Objects and Their State (page 381)

 

 

QUESTION 143

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 following SQL statement to retrieve an instance of a DataSet object named ds:

 

SELECT CustomerID, CompanyName, ContactName, Address, City

 

FROM dbo.Customers

 

You need to query the DataSet object to retrieve only the rows where the ContactName field is not NULL.

 

Which code segment should you use?

 

A.

from row in ds.Tables[0].AsEnumerable()

where (string)row[“ContactName”] != null

select row;

B.

from row in ds.Tables[0].AsEnumerable()

where row.Field<string>(“ContactName”) != null

select row;

C.

from row in ds.Tables[0].AsEnumerable()

where !row.IsNull((string)row[“ContactName”])

select row;

D.

from row in ds.Tables[0].AsEnumerable()

where !Convert.IsDBNull(row.Field<string>(” ContactName “))

select row;

 

Correct Answer: B

Explanation:

Field<T>(DataRow, String) Provides strongly-typed access to each of the column values in the specified row.

The Field method also supports nullable types.

 

 

 

 

 

 

QUESTION 144

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

 

clip_image002

 

The application contains a class as shown in the following code segment.

 

public class MyBaseClass : EntityObject

 

{

 

….

 

}

 

You need to ensure that all generated entities inherit from MyBaseClass.

 

What should you do?

 

A.

Change MyBaseClass to inherit from ObjectContext.

B.

Create a new ObjectQuery that uses MyBaseClass as the type parameter.

C.

Modify the generated code file so that all entities inherit from MyBaseClass.

D.

Use the ADO.NET EntityObject Generator template to configure all entities to inherit from MyBaseClass.

 

Correct Answer: D

Explanation:

You can use the Text Template Transformation Toolkit (T4) to generate your entity classes, and Visual Studio.

NET provides the T4 EntityObject Generator template by which you can control the entity object generation.

Visual Studio .NET also provides the T4 SelfTracking Entity Generator template by which you can create and control the Add an EntityObject Generator to your project and add the new modification to the text template.self-tracking entity classes. Add an EntityObject Generator to your project and add the new modification to the text template.

 

CHAPTER 6 ADO.NET Entity Framework

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

The EntityObject Generator (page 403-404)

http://blogs.msdn.com/b/efdesign/archive/2009/01/22/customizing-entity-classes-with-t4.aspx

 

 

QUESTION 145

You use Microsoft .NET Framework 4 to develop an application that connects to a local Microsoft SQL Server 2008 database. The application can access a high-resolution timer.

 

You need to display the elapsed time, in sub-milliseconds (<1 millisecond), that a database query takes to execute.

 

Which code segment should you use?

 

A.

int Scare = Environment.TickCount;

command.ExecuteNonQuery();

int Elapsed = (Environment.TickCount) = Start;

Console.WriteLine(“Time Elapsed: {0:N3} ins”, Elapsed);

B.

Stopwatch sw = Stopwatch.StartNew();

command.ExecuteNonQuery() ;

sw.Stop();

Console.WriteLine(“Time Elapsed: {0:N3} ms”,

sw.Elapsed.TotalHilliseconds);

C.

DateTime Start = DateTime.UtcNow;

command.ExecuteNonQuery();

TimeSpan Elapsed = DateTime.UtcNow = Start;

Console.WriteLine(“Time Elapsed: {0:N3} ms”,

Elapsed.Milliseconds);

D.

Stopwatch sw = new Stopwatch();

sw.Start() ;

command.ExecuteNonQuery();

sw.Stop();

Console. WriteLine (“Time Elapsed: {0:N3} ms”, sw.ElapsedHilliseconds);

 

Correct Answer: D

Explanation:

http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx

 

 

QUESTION 146

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 need to create a database from your model.

 

What should you do?

 

A.

Run the edmgen.exe tool in FullGeneration mode.

B.

Run the edmgen.exe tool in FromSSDLGeneration mode.

C.

Use the Update Model Wizard in Visual Studio.

D.

Use the Generate Database Wizard in Visual Studio. Run the resulting script against a Microsoft SQL Server database.

 

Correct Answer: D

Explanation:

To update the database, right-click the Entity Framework designer surface and choose Generate Database From Model.

The Generate Database Wizard produces a SQL script file that you can edit and execute.

 

 

QUESTION 147

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database. You need to prevent dirty or phantom reads. Which IsolationLevel should you use?

 

A.

Snapshot

B.

Serializable

C.

ReadUncommited

D.

ReadCommitted

 

Correct Answer: A

Explanation:

Unspecified A different isolation level than the one specified is being used, but the level cannot be determined.

When using OdbcTransaction, if you do not set IsolationLevel or you set IsolationLevel to Unspecified, the transaction executes according to the isolation level that is determined by the driver that is being used.

Chaos The pending changes from more highly isolated transactions cannot be overwritten. ReadUncommitted A dirty read is possible, meaning that no shared locks are issued and no exclusive locks are honored.

ReadCommitted Shared locks are held while the data is being read to avoid dirty reads, but the data can be changed before the end of the transaction, resulting in non-repeatable reads or phantom data.

RepeatableRead Locks are placed on all data that is used in a query, preventing other users from updating the data.

Prevents non-repeatable reads but phantom rows are still possible. Serializable A range lock is placed on the DataSet, preventing other users from updating or inserting rows into the dataset until the transaction is complete. Snapshot Reduces blocking by storing a version of data that one application can read while another is modifying the same data.

Indicates that from one transaction you cannot see changes made in other transactions, even if you requery.

IsolationLevel Enumeration

http://msdn.microsoft.com/e

n-us/library/system.data.isolationlevel.aspx

Isolation Levels in Database Engine

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

SET TRANSACTION ISOLATION LEVEL (Transact-SQL)

http://msdn.microsoft.com/ru-ru/library/ms173763.aspx

 

 

QUESTION 148

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Microsoft ASP.NET application.

 

You want to connect the application to a Microsoft SQL Server Express 2008 database named MyDatabase. The primary database file is named MyDatabase.mdf and it is stored in the App_Data folder.

 

You need to define the connection string.

 

Which connection string should you add to the Web.config file?

 

A.

Data Source=localhost; Initial Catalog=MyDataBase; Integrated Security=SSPI; User Instance=True

B.

Data Source=.SQLEXPRESS; Initial Catalog=MyDataBase; Integrated Security=True; User Instance=True

C.

Data Source=.SQLEXPRESS; AttachDbFilename=|DataDirectory|MyDatabase.mdf; Integrated Security=True; User Instance=True

D.

Data Source=SQLEXPRESS; AttachDbFilename=|DataDirectory|App_DataMyDatabase.mdf; Integrated Security=SSPI; User Instance=True

 

Correct Answer: C

Explanation:

CHAPTER 2 ADO.NET Connected Classes

Lesson 1: Connecting to the Data Store

Attaching to a Local SQL Database File with SQL Express (page 73)

 

 

QUESTION 149

DRAG DROP

You plan to generate the following Transact-SQL script from an Entity Data Model (EDM) by using the Entity Framework Designer:

 

clip_image003

 

 < /p>

You create an entity named Employee.

 

You need to identify the data types for the properties of the Employee entity.

 

What should you identify?

 

To answer, drag the appropriate data types to the correct statements. Each data type 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_image005

 

 

QUESTION 150

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Wmdows Communication Foundation (WCF) Data Services service.

 

The service connects to a Microsoft SQL Server 2008 database. The service is hosted by an internet Information Services (IIS) 6.0 server.

 

You need to ensure that applications authenticate against user information stored in the database before the application is allowed to use the service.

 

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

 

A.

Configure IIS to require basic authentication

B.

Configure IIS to allow anonymous access

C.

Configure IIS to require Windows authentication

D.

Enable the WCF Authentication Service

E.

Modify the Data Services service to use a Microsoft ASP.NET membership provider

 

Correct Answer: BE

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…