[Free] New Updated (October) Microsoft 70-516 Real Exam 1-10

Ensurepass

 

QUESTION 1

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

 

The application contains the following XML document.

 

<bib>

 

<book title=”TCP/IP Illustrated” year=”1994″>

 

<author> Author1 </author>

 

</book>

 

<book title=”Programming in Unix” year=”1992″>

 

<author> Author1 </author>

 

<author> Author2 </author>

 

<author> Author3 </author>

 

</book>

 

<book title=”Data on the Web” year=”2000″>

 

<author> Author4 </author>

 

<author> Author3 </author>

 

</book>

 

</bib>

 

You add the following code fragment. (Line numbers are included for reference only.)

 

01 public IEnumerable<XElement> GetBooks(string xml)

 

02 {

 

03 XDocument doc = XDocument.Parse(xml);

 

04

 

05 }

 

You need to return a list of book XML elements that are authored by Author1.

 

Which code segment should you insert at line 04?

 

A.

return doc.Element(“bib”)

.Elements()

.SelectMany(e1 => e1.Elements()

.Where(e2 => e2 .Equals(new XElement(“author”,” Author1 “))));

B.

return doc.Element(“bib”)

.Elements()

.SelectMany(e1 => e1.Elements()

.Where(e2 => (string)e2 == ” Author1 “));

C.

return doc.Element(“bib”)

.Elements()

.Where(e1 => e1.Elements().Any(e2 => (string)e2 == ” Author1 “));

D.

return doc.Element(“bib”)

.Elements()

.Where(e1=> e1.Elements().Any(e2 => e2 .Equals(new XElement(“author”,”Author1″))));

 

Correct Answer: C

 

 

QUESTION 2

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 model includes the entity shown in the following exhibit.

 

clip_image001

 

You need to add a function that returns the number of years since a person was hired.

 

You also need to ensure that the function can be used within LINQ to Entities queries.

 

What should you do?

 

A.

Add the following code fragment to the .edmx file.

<Function Name=”YearsSinceNow” ReturnType=”Edm.Int32″>

<Parameter Name=”date” Type=”Edm.DateTime” />

<DefiningExpression>

Year(CurrentDateTime()) – Year(date)

</DefiningExpression>

</Function>

Add the following function to the entity class definition.

[EdmComplexType(“SchoolModel”, “YearsSinceNow”)]

public static int YearsSinceNow(DateTime date)

{

throw new NotSupportedException(“Direct calls are not supported.”); }

B.

Add the following code fragment to the .edmx file.

<Function Name=”YearsSinceNow” ReturnType=”Edm.Int32″>

<Parameter Name=”date” Type=”Edm.DateTime” />

<DefiningExpression>

Year(CurrentDateTime()) – Year(date)

</DefiningExpression>

</Function>

Add the following function to the entity class definition.

[EdmFunction(“SchoolModel”, “YearsSinceNow”)]

public static int YearsSinceNow(DateTime date)

{

throw new NotSupportedException(“Direct calls are not supported.”); }

C.

Add the following code fragment to the .edmx file.

<Function Name=”YearsSinceNow” ReturnType=”Edm.Int32″>

<Parameter Name=”date” Type=”Edm.DateTime” />

</Function>

Add the following function to the entity class definition.

[EdmFunction(“SchoolModel”, “YearsSinceNow”)]

public static int YearsSinceNow(DateTime date)

{

return Year(CurrentDateTime() – Year(date));

}

D.

Use the Entity Data Model Designer to create a complex property named YearsSinceNow that can be accessed through the LINQ to Entities query at a later time.

 

Correct Answer: B

Explanation:

How to: Call Model-Defined Functions in Queries

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

How to: Call Model-Defined Functions as Object Methods

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

 

 

QUESTION 3

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 find out whether a collection is empty.

 

Which entity set operator should you use?

 

A.

ANYELEMENT

B.

EXCEPT

C.

EXISTS

D.

IN

 

Correct Answer: C

Explanation:

EXISTS Determines if a collection is empty.

Entity SQL Reference

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

 

 

 

 

 

 

 

 

QUESTION 4

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the Entity Framework.

 

You need to execute custom logic when an entity is attached to the ObjectContext.

 

What should you do?

 

A.

Create a partial method named OnStateChanged in the partial class for the entity.

B.

Create a partial method named OnAttached in the partial class for the entity.

C.

Create an event handler to handle the ObjectStateManagerChanged event.

D.

Create an event handler to handle the ObjectMaterialized event.

 

Correct Answer: C

Explanation:

ObjectStateManagerChanged Occurs when entities are added to or removed from the state manager.

ObjectMaterialized Occurs when a new entity object is created from data in the data source as part of a query or load operation.

ObjectStateManagerChanged Event

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

ObjectMaterialized Event

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

 

 

QUESTION 5

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You use Microsoft ADO.NET Entity Data Model (EDM) to mode entities.

 

You create an entity named Person with a schema defined by the following XML fragment

 

<EnlityType l1ame’CPerson”

 

<Key>

 

<PropertyRef Name=”Personld” I>

 

</Key>

 

<Property Name=”Personid” Typel=”int32″ Nullable=”false” />

 

<Property Name=”CompaiyName” Type=”String”/>

 

<Property Name=”ContactName” Type”Strng”/>

 

<Property Name=”ContactTitle” Type=’String”/>

 

<Proper1y Name=”Address” Type=”String”/>

 

</Entitytype>

 

You need to ensure that entities within the application are able to add properties related to the city, region, and country of Person’s address. What should you do?

A.

“Create a new complex type named CAddress that contains the properties for city, region, and country.

“Change the type ot the Address property in CPerson to “Self.CAddress”.

B.

“Create a SubEntity named Address.

“Map the SubEntity to a stored procedure that retrieves city, region, and country.

C.

“Create a new entity named Address.

“Add a person ID property to filter the results to display only the City, Region, and Country properties for a specific Person entity.

D.

“Create a view named Name that returns city, region, and country along with person IDs.

“Add a WHERE clause to filter the results to display only the City, Region and Country properties for a specific Person entity.

 

Correct Answer: A

 

 

QUESTION 6

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

 

You plan to deploy the application to several shared client computers.

 

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

 

01 Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);

 

02

 

03 config.Save();

 

04 …

 

You need to encrypt the connection string stored in the .config file.

 

Which code segment should you insert at line 02?

 

A.

ConnectionStringsSection section = config.GetSection(“connectionString”) as ConnectionStringsSection;

section.SectionInformation.ProtectSection(“DataProtectionConfigurationProvider”);

B.

ConnectionStringsSection section = config.GetSection(“connectionStrings”) as ConnectionStringsSection;

section.SectionInformation.ProtectSection(“DataProtectionConfigurationProvider”);

C.

ConnectionStringsSection section = config.GetSection(“connectionString”) as ConnectionStringsSection;

section.SectionInformation.ProtectSection(“RsaProtectedConfigurationProvider”);

D.

ConnectionStringsSection section = config.GetSection(“connectionStrings”) as ConnectionStringsSection;

section.SectionInformation.ProtectSection(“RsaProtectedConfigurationProvider”);

 

Correct Answer: D

Explanation:

You encrypt and decrypt the contents of a Web.config file by using System.Configuration.

DPAPIProtectedConfigurationProvider,

which uses the Windows Data Protection API (DPAPI) to encrypt and decrypt data, or 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 2 ADO.NET Connected Classes

Lesson 1: Connecting to the Data Store

Storing Encrypted Connection Strings in Web Applications (page 76) Securing Connection Strings

http://msdn.microsoft.com/en-us/library/89211k9b(v=vs.80).aspx

 

 

QUESTION 7

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

 

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

 

01 class DataAccessLayer

 

02 {

 

03 private static string connString;

 

04

 

05 …

 

06 public static DataTable GetDataTable(string command){ 08 …

 

07

 

08 …

 

09 }

 

10 }

 

You need to define the connection life cycle of the DataAccessLayer class. You also need to ensure that the application uses the minimum number of connections to the database.

 

What should you do?

 

A.

Insert the following code segment at line 04.

private static SqlConnection conn = new SqlConnection(connString);

public static void Open(){

conn.Open();

}

public static void Close(){

conn.Close();

}

B.

Insert the following code segment at line 04.

private SqlConnection conn = new SqlConnection(connString);

public void Open(){

conn.Open(); }

public void Close(){

conn.Close();

}

C.

Replace line 01 with the following code segment.

class DataAccessLayer : IDisposable

Insert the following code segment to line 04.

private SqlConnection conn = new SqlConnection(connString);

public void Open(){

conn.Open();

}

public void Dispose(){

conn.Close();

}

D.

Insert the following code segment at line 07.

using (SqlConnection conn = new SqlConnection(connString)){

conn.Open();

}

 

Correct Answer: D

Explanation:

One thing you should always do is to make sure your connections are always opened within a using statement.

Using statements will ensure that even if your application raises an exception while the connection is open, it will always be closedreturned to the pool) before your request is complete. This is very important, otherwise there could be connection leaks.

 

 

QUESTION 8

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 allows users to make changes to entities while disconnected from the central data store.

 

You need to ensure that when the user connects to the central data store and retrieves new data, the application meets the following requirements:

 

clip_image003Changes made to the local data store in disconnected mode are preserved.

clip_image003[1]Entities that have already been loaded into the local data store, but have not been modified by the user, are updated with the latest data.

 

What should you do?

 

A.

Call the query’s Execute method by using the MergeOptions.AppendOnly option.

B.

Call the query’s Execute method by using the MergeOptions.OverwriteChanges option.

C.

Call the Refresh method of ObjectContext by using the RefreshMode.ClientWins method.

D.

Call the Refresh method of ObjectContext by using the RefreshMode.StoreWins option.

 

Correct Answer: C

 

 

QUESTION 9

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Communication Foundation (WCF) Data Services service. You deploy the service to the following URL: http://contoso.com/ Northwind.svc.

 

You want to query the WCF Data Services service to retrieve a list of customer objects.

 

You need to ensure that the query meets the following requirements:

clip_image003[2]“Only customers that match the following filter criteria are retrieved: City=”Seattle” AND Level > 200.

clip_image003[3]“Data is sorted in ascending order by the ContactName and Address properties.

 

Which URL should you use for the query?

 

A.

http: //contoso.com/Northwind.svc/Customers?City=Seattle & Level gt 200 & $orderby=ContactName, Address

B.

http: //contoso.com/Northwind.svc/Customers?City=Seattle & Level gt 200 & $orderby=ContactName and Address

C.

http: //contoso.com/Northwind.svc/Customers?$filter=City eq ‘Seattle’ and Level gt 200 & $orderby=ContactName,Address

D.

http: //contoso.com/Northwind.svc/Customers?$filter=City eq ‘Seattle’ and Level gt 200 & $orderby=ContactName and Address

 

Correct Answer: C

Explanation:

CHAPTER 7 WCF Data Services

Lesson 1: What Is WCF Data Services?

Working with Filters (page 474)

Accessing the Service from a Web Browser (WCF Data Services Quickstart)

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

Accessing Data Service Resources (WCF Data Services) http://msdn.microsoft.com/en-us/library/dd728283.aspx

 

 

QUESTION 10

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database by using SQL Server authentication. The application contains the following connection string.

 

SERVER=DBSERVER-01; DATABASE=pubs; uid=sa; pwd=secret;

 

You need to ensure that the password value in the connection string property of a SqlConnection object does not exist after the Open method is called.

 

What should you add to the connection string?

 

A.

Persist Security Info=True

B.

Trusted_Connection=True

C.

Persist Security Info=False

D.

Trusted_Connection=False

 

Correct Answer: C

Explanation:

The Persist Security Info property specifies whether the data source can persist sensitive authentication information such as a password.

Persist Security Info Property

http://msdn.microsoft.com/en-us/library/aa214039(v=sql.80).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…