[Free] New Updated (October) Microsoft 70-516 Real Exam 91-100

Ensurepass

 

QUESTION 91

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.

 

The application includes a Customer entity along with a CustomerKey property of the Guid type as shown in the following exhibit.

 

clip_image001

 

You discover that when the application adds a new instance of a Customer, calling the SaveChanges method results in the following error message:

 

“Server generated keys are only supported for identity columns.”

 

You need to ensure that the application can add new Customer entities.

 

What should you do?

 

A.

Add a handler for the ObjectContext.SavingChanges event. In the event handler, set the CustomerKey value.

B.

Add a handler for the ObjectContext.ObjectMaterialized event. In the event handler, set the CustomerKey value.

C.

Call the ObjectContext.Attach method before saving a Customer entity.

D.

Call the ObjectContext.CreateEntityKey method before saving a Customer entity.

 

Correct Answer: A

Explanation:

SavingChanges() Event Occurs when changes are saved to the data source. ObjectMaterialized() Event Occurs when a new entity object is created from data in the data source as part of a query or load operation. Attach() Method Attaches an object or object graph to the object context when the object has an entity key.

CreateEntityKey() Creates the entity key for a specific object, or returns the entity key if it already exists.

ObjectContext Class

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

 

 

QUESTION 92

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

 

You are creating the data layer of the application.

 

You write the following code segment. (Line numbers are included for reference only.)

 

01 public static SqlDataReader GetDataReader(string sql) {

 

02 SqlDataReader dr – null;

 

03 return dr;

 

04

 

05 }

 

You need to ensure that the following requirements are met:

 

clip_image003The SqlDataReader returned by the GetDataReader method can be used to retrieve rows from the database.

clip_image003[1]SQL connections opened within the GetDataReader method will close when the SqlDataReader is closed.

 

Which code segment should you insert at line 03?

 

A.

SqlConnection cnn = new SqlConnectlon(strCnn);

SqlCommand cmd = new SqlCottmandfsql, cnn);

cnn.Open() ;

try {

dr = cmd.ExecuteReader();

cnn.Close();

{

catch {

throw;

}

B.

SqlConnection cnn = new SqlConnection(scrCnn);

SqlCommand cmd = new SqlCommandfsql, cnn);

cnn.Open () ;

try {

dr = cmd.ExecuceReader(CommandBehavior.CloseConnection);

{

catch {

cnn.Close();

throw;

}

C.

using (SqlConnection cnn = new SqlConnection(strCnn)) {

try {

SqlCommand cmd = new SqlCommand(sql, cnn);

cnn.Open();

dr = cmd.ExecuteReader(); ) catch

{

throw;

}

}

D.

SqlConnection cnn = new SqlConnection(strCnn);

SqlCommand cmd = new SqlCommand(sql, cnn);

cnn.Open() ;

try

{

dr = cmd.ExecuteReader();

}

finally

{

cnn.Close() ;

}

 

Correct Answer: B

Explanation:

CommandBehavior.CloseConnection When the command is executed, the associated Connection object is closed when the associated DataReader object is closed.

CommandBehavior Enumeration

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

SqlCommand.ExecuteReader Method (CommandBehavior)

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

 

 

QUESTION 93

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 Entity SQL to retrieve data from the database. You need to enable query plan caching. Which object should you use?

 

A.

EntityCommand

B.

EntityConnection

C.

EntityTransaction

D.

EntityDataReader

 

Correct Answer: A

Explanation:

Whenever an attempt to execute a query is made, the query pipeline looks up its query plan cache to see whether the exact query is already compiled and available. If so, it reuses the cached plan rather than building a new one. If a match is not found in the query plan cache, the query is compiled and cached. A query is identified by its Entity SQL text and parameter collection (names and types). All text comparisons are case-sensitive.

Query plan caching is configurable through the EntityCommand. To enable or disable query plan caching through System.Data.EntityClient.EntityCommand. EnablePlanCaching, set this property to true or false. Disabling plan caching for individual dynamic queries that are unlikely to be used more then once improves performance.

You can enable query plan caching through EnablePlanCaching.

Query Plan Caching

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

 

 

QUESTION 94

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

?

 

A.

context.Refresh(RefreshMode.StoreWins, entity);

B.

context.LoadProperty(entity, “Client”,

MergeOption.OverwriteChanges);

C.

context.AcceptAllChanges();

D.

context.LoadProperty[entity, “Server”,

MergeOption.OverwriteChanges);

 

Correct Answer: A

Explanation:

LoadProperty(Object, String) Explicitly loads an object related to the supplied object by the specified navigation property and using the default merge option. AcceptAllChanges Accepts all changes made to objects in the object context. Refresh(RefreshMode, Object) Updates an object in the object context with data from the data source.

ObjectContext.Refresh Method (RefreshMode, Object)

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

 

 

QUESTION 95

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses LINQ to SQL. The application contains the following model.

 

clip_image004

 

Each region contains a single vendor. Customers order parts from the vendor that is located in their region.

You need to ensure that each row in the Customer table references the appropriate row from the Vendor table.

 

Which code segment should you use?

 

A.

SalesDataContext dc = new SalesDataContext( “…” );

var query = from v in dc.Vendors

join c in dc.Customers on v.VendorlD equals c.VendorID

select new { Vendor = v, Customer= c };

foreach (var u in query)

{

B.

Customer.Region = u.Vendor.Region;

}

dc.SubmitChanges();

C.

SalesDataContext dc = new SalesDataContext( “…” );

var query = from c in dc.Customers

join v in dc.Vendors on c.VendorlD equals v.VendorID

select new { Customer = C.Vendor = v };

foreach (var u in query)

{

D.

Vendor.Region = u.Customer.Region;

dc.SubmitChanges();

E.

SalesDataContext dc = new SalesDataContext ( “…” );

var query = from v in dc.Vendors

join c in dc.Customers on v.Region equals c.Region

select new { Vendor =v, Customer = c };

foreach (var u in query)

{

F.

Customer.VendorlD = u.Vendor.VendorlD;

}

dc.SubmitChanges();

G.

SalesDataContext dc = new SalesDataContext ( “…” );

var query = from c in dc.Customers

join v in dc.Vendors on c.Region equals v.Region

select new { Customer = C.Vendor = v };

foreach (var u in query)

{

H.

Vendor.VendorlD = u.Customer.VendorID;

}

dc.SubmitChanges();

 

Correct Answer: C

 

 

 

 

 

 

 

 

 

 

 

 

 

QUESTION 96

DRAG DROP

You have a Cable named Tablel that contains two columns named Columnl and Column2. Columnl contains string data. Column2 contains image files.

 

You create the following code:

 

clip_image005

 

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_image007

 

Correct Answer:

clip_image009

 

 

 

 

 

 

 

 

 

 

 

QUESTION 97

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 uses DataContexts to query the database.

 

The application meets the following requirements:

 

clip_image003[2]Stores customer data offline.

clip_image003[3]Allows users to update customer records while they are disconnected from the server.

clip_image003[4]Enables offline changes to be submitted back to the SQL Server by using the DataContext object.

 

You need to ensure that the application can detect all conflicts that occur between the offline customer information submitted to the SQL Server and the server version.

 

You also need to ensure that you can roll back local changes.

 

What should you do?

 

A.

Add a try/catch statement around calls to the SubmitChanges method of the DataContext object and catch ChangeConflictExceptions.

B.

Add a try/catch statement around calls to the SubmitChanges method of the DataContext object and catch SqlExceptions.

C.

Override the Update operation of the DataContext object. Call the ExecuteDynamicUpdate method to generate the update SQL.

D.

Call the SubmitChanges method of the DataContext object. Pass System.Data.Linq.ConflictMode.ContinueOnConflict to the method.

 

Correct Answer: D

Explanation:

FailOnFirstConflict Specifies that attempts to update the database should stop immediately when the first concurrency conflict error is detected. ContinueOnConflict Specifies that all updates to the database should be tried, and that concurrency conflicts should be accumulated and returned at the end of the process. ExecuteDynamicUpdate() Method Called inside update override methods to redelegate to LINQ to SQL the task of generating and executing dynamic SQL for update operations.

ConflictMode Enumeration

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

DataContext.ExecuteDynamicUpdate Method

http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.executedynamicupdate.aspx

 

 

QUESTION 98

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.

 

You need to ensure that the entities are self-tracking.

 

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

 

A.

Change the Code Generation Strategy option from Default to None.

B.

Change the Transform Related Text Templates On Save option to False.

C.

Add an ADO.NET Self-Tracking Entity Generator to the model.

D.

Add an ADO.NET EntityObject Generator to the model.

Correct Answer: C

Explanation:

The ADO.NET Self-Tracking Entity Generator text template generates the object-layer code that consists of a custom typed ObjectContext and entity classes that contain self- tracking state logic so that the entities themselves keep track of their state instead of ObjectContext doing so.

Probably the best usage of self-tracking entities is when working with N-tier applications.

CHAPTER 6 ADO.NET Entity Framework

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

The Self-Tracking Entity Generator (page 405)

ADO.NET Self-Tracking Entity Generator Template

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

 

 

QUESTION 99

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 Entity SQL of the ADO .NET Entity Framework to retrieve data from the database.

 

You need to define a custom function in the conceptual model. You also need to ensure that the function calculates a value based on properties of the object.

 

Which two XML element types should you use? (Each correct answer presents part of the solution Choose two.)

 

A.

Function

B.

Function Import

C.

Dependent

D.

Association

E.

DefiningExpression

 

Correct Answer: AE

Explanation:

CHAPTER 6 ADO.NET Entity Framework

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

Model-Defined Functions (page 413)

 

 

QUESTION 100

You use Microsoft .NET Framework 4 to develop an ASP.NET 4 Web application. You need to encrypt the connection string information that is stored in the web.config file. The application is deployed to multiple servers.

 

The encryption keys that are used to encrypt the connection string information must be exportable and importable on all the servers.

 

You need to encrypt the connection string section of the web.config file so that the file can be used on all of the servers.

 

Which code segment should you use?

 

A.

Configuration config = WebConfigurationManager.OpenWebConfiguration(“~”) ; ConnectionStringsSection section =

(ConnectionStringsSection)config.GetSection(“connectionStrings”); section.Sectionlnformation.ProtectSection(“RsaProtectedConfigurationProvider”); config.Save();

B.

Configuration config = WebConfigurationManager.OpenMachineConfiguration(“~”); ConnectionStringsSection section =

(ConnectionStringsSection)config.GetSection(“connectionStrings”); section.Sectionlnformation.ProtectSection(“RsaProtectedConfigurationProvider’*); config.Save();

C.

Configuration config = WebConfigurationManager.OpenWebConfiguration (“~”) ; ConnectionStringsSection section =

(ConnectionStringsSection)config.GetSection(“connectionStrings”) ; section.Sectionlnformation.ProtectSection(“DpapiProtectedConfigurationProvider”); config.Save ();

D.

Configuration config = WebConfigurationManager.OpenMachineConfiguration (“~”) ; ConnectionStringsSection section =

(ConnectionStringsSection)config.GetSection(“connectionStrings”) ; section.Sectionlnformation.ProtectSection(“DpapiProtectedConfigurationProvider”); config.Save () ;

 < /font>

Correct Answer: A

Explanation:

You encrypt and decrypt the contents of a Web.config file by using System.Configuration . DPAPIProtectedConfigurationProvider from the System.Configuration.dll assembly, which uses the Windows Data Protection API (DPAPI) to encrypt and decrypt data, or by using System.Configuration.

RSAProtectedConfigurationProvider, which uses the RSA encryption algorithm to encrypt and decrypt data.

When you use the same encrypted configuration file on many computers in a web farm, only System.

Configuration.RSAProtectedConfigurationProvider enables you to export the encryption keys that encrypt the data and import them on another server. This is the default setting.

CHAPTER 8 Developing Reliable Applications

Lesson 3: Protecting Your Data

Storing Encrypted Connection Strings in Web Applications (page 555)

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…