[Free] New Updated (October) Microsoft 70-516 Real Exam 201-210

Ensurepass

 

 

QUESTION 201

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:

 

It can be used by an ObjectContext.

 

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 202

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 ADO.NET LINQ to SQL model to retrieve data from the database.

 

The application contains the Category and Product entities, as shown in the following exhibit.

 

clip_image001

 

You need to ensure that LINQ to SQL executes only a single SQL statement against the database.

 

You also need to ensure that the query retrieves the list of categories and the list of products.

 

Which code segment should you use?

 

A.

Using dc As New NorthwindDataContext()

dc.ObjectTrackingEnabled = False

Dim categories As var = From c In dc.Categories _

Select c

For Each category As var In categories

Console.WriteLine(“{0} has {1} products”, category.CategoryName,

category.Products.Count)

Next

End Using

B.

Using dc As New NorthwindDataContext()

dc.DeferredLoadingEnabled = False

Dim dlOptions As New DataLoadOptions()

dlOptions.LoadWith(Of Category)(Function(c As ) c.Products)

dc.LoadOptions = dlOptions

Dim categories As var = From c In dc.Categories _

Select c

For Each category As var In categories

Console.WriteLine(“{0} has {1} products”, category.CategoryName,

category.Products.Count)

Next

End Using

C.

Using dc As New NorthwindDataContext()

dc.DefferredLoadingEnabled = False

Dim categories As var = From c In dc.Categories _

Select c

For Each category As var In categories

Console.WriteLine(“{0} has {1} products”, category.CategoryName,

category.Products.Count)

Next< /p>

End Using

D.

Using dc As New NorthwindDataContext()

dc.DeferredLoadingEnabled = False

Dim dlOptions As New DataLoadOptions()

dlOptions.Asso ciateWith(Of Category)(Function(c As ) c.Products)

dc.LoadOptions = dlOptions

Dim categories As var = From c In dc.Categories _

Select c

For Each category As var In categories

Console.WriteLine(“{0} has {1} products”, category.CategoryName,

category.Products.Count)

Next

End Using

 

Correct Answer: B

Explanation:

DataLoadOptions Class Provides for immediate loading and filtering of related data. DataLoadOptions.LoadWith(LambdaExpression) Retrieves specified data related to the main target by using a lambda expression.

You can retrieve many objects in one query by using LoadWith. DataLoadOptions.AssociateWith(LambdaExpression) Filters the objects retrieved for a particular relationship.

Use the AssociateWith method to specify sub-queries to limit the amount of retrieved data.

DataLoadOptions Class

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

How to: Retrieve Many Objects At Once (LINQ to SQL)

http://msdn.microsoft.com/en-us/library/Bb386917(v=vs.90).aspx

How to: Filter Related Data (LINQ to SQL)

http://msdn.microsoft.com/en-us/library/Bb882678(v=vs.100).aspx

 

 

QUESTION 203

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application. A file named books.xml contains the following XML.

 

<bib>

 

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

 

<author>Author1</author>

 

<author>Author2</author>

 

<author> Author 3 </out hor>

 

</book>

 

</bib>

 

The application must generate an XML result that contains an XML element named BookTitle for each book. The text content of the element must contain the title of the book.

 

You need to create a query that generates the new XML result.

 

What should you do?

 

A.

Dim document As XDocument = XDocument. Load (“books.xml”)

Dim query = From node In document.Descendants()

Where node.Name.LocalName = “book”

Select New XElement(“BookTitle”, node.FirstAttribute.Value)

B.

Dim document As XDocument = XDocument.Load(“books.xml”)

Dim query = From node In document.DescendantNodes()

Where node.ToString()= “book”

Select New XText(“BookTitle” & node.ToString())

C.

Dim document As XDocument = XDocument.Load(“books.xml”)

Dim query = From node In document.Descendants()

Uhere node.Name.LocalName = “book”

Select New XElement(“BookTitle”).Value –

node.FirstAttribute.Value

D.

Dim document As XDocument = XDocument.Load(“books.xml”)

Dim query = From node In document.DescendantNodes()

Where node.ToString() = “book”

Select New XElement(“BookTitle”,

node.ToString())

 

Correct Answer: A

 

 

QUESTION 204

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the Entity Framework. You create an Entity Data Model (EDM) named Model. You need to ensure that the Storage Schema Definition Language (SSDL) of the EDM can be modified without rebuilding the application. What should you do?

 

A.

Set the Metadata Artifact Processing property to Embed in Output Assembly and use the following connection string.

metadata=res://*/Model.csdl|res://*/Model.ssdl|

res://*/Model.msl;

provider=System.Data.SqlClient;

provider connection string=”& “

B.

Set the Metadata Artifact Processing property to Copy to Output Directory and use the following connection string.

metadata=res://*/Model.csdl|res://*/Model.ssdl|

res://*/Model.msl;

provider=System.Data.SqlClient;

provider connection string& =”& “

C.

Set the Metadata Artifact Processing property to Embed in Output Assembly and use the following connection string.

metadata=.Model.csdl|.Model.ssdl|.Model.msl;

provider=System.Data.SqlClient;

provider connection string=”& “

D.

Set the Metadata Artifact Processing property to Copy to Output Directory and use the following connection string.

metadata=.Model.csdl|.Model.ssdl|.Model.msl;

provider=System.Data.SqlClient;

provider connection string& =”& “

 

Correct Answer: D

Explanation:

How to: Copy Model and Mapping Files to the Output Directory (Entity Data Model Tools)

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

 

QUESTION 205

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database. You use the ADO.NET Entity Framework Designer to model entities. You add the following stored procedure to the database, and you add a function import to the model.

 

CREATE PROCEDURE [dbo]. [InsertDepartment]

 

@Name nvarchar(50), @ ID int NULL OUTPUT

 

AS

 

INSERT INTO Department (Name) VALUES (@Name)

 

SELECT 6ID = SCOPE_IDENTITY()

 

You need to insert a new department and display the generated ID.

 

Which code segment should you use?

 

A.

Using context As New SchoolEntities()

Dim id As ObjectParameter = Nothing context.InsectDepartment(“Department 1”, id)

Console.WriteLine(id.Value)

End Using

B.

Using context As New SchoolEntities()

Dim id = New ObjectParameter(“ID”, GetType(Integer)) context.InsertDepartment(“Department 1”, id)

Console.WriteLine(id.Value)

End Using

C.

Using context As New SchoolEntities()

Dim id = New ObjectParameter(“ID”, Nothing) context.InsertDepartment(“Department 1”, id)

Console.WriteLine(id.Value)

End Using

D.

Using contexc As New SchoolEntities()

Dim id = context.InsertDepartment(“Department 1”, Nothing)

Console.WriteLine(id)

End Using

 

Correct Answer: B

Explanation:

http://blogs.microsoft.co.il/blogs/gilf/archive/2010/05/09/how-to-retrieve-stored-procedure-output-parameters-inentity-framework.aspx

 

 

QUESTION 206

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 stores encrypted debit card numbers and PIN codes in the database.

 

You need to ensure that PIN codes cannot be extracted from the database.

 

Which cryptography provider should you use?

 

A.

SHA1CryptoServiceProvider

B.

DSACryptoServiceProvider

C.

AesCryptoServiceProvider

D.

MD5CryptoServiceProvider

 

Correct Answer: A

 

 

QUESTION 207

You use Microsoft .NET Framework 4 to develop an application.

 

The configuration file contains the following code segment.

 

<configuration>

 

<connectionStrings>

 

<add name=”AdventureWorksLT”

 

connectionString=”Data Source=SQL01;

 

Initial Catalog=AdventureWorksLT;

 

Integrated Security=True;”

 

providerName=”System.Data.SqlClient”/>

 

</connectionStrings>

 

</configuration>

 

You need to retrieve the connection string named AdventureWorksLT from the configuration file.

 

Which line of code should you use?

 

A.

Dim connectionString = ConfigurationManager _

.ConnectionStrings(“AdventureWorksLT”).ConnectionString

B.

Dim connectionString = ConfigurationManager _

.ConnectionStrings(“AdventureWorksLT”).Name

C.

Dim connectionString = ConfigurationManager _

.AppSettings(“AdventureWorksLT”)

D.

Dim connectionString = ConfigurationSettings _

.AppSettings(“AdventureWorksLT”)

 

Correct Answer: A

 

 

 

 

 

 

 

 

 

 < /p>

 

QUESTION 208

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 as shown in the following diagram.

 

clip_image002

 

You create an ObjectContext instance named objectContext1 and use it to create a SalesPerson instance named person1. You also create an ObjectContext instance named objectContext2 and use it to create a SalesTerritory instance named territory1. You need to create and persist a relationship between person1 and territory1.

 

What should you do?

 

A.

1. Detach person1 from objectContext1.

2. Attach person1 to objectContext2.

3. Set the SalesTerritory property of person1 to territory1.

4. Call SaveChanges on objectContext2.

B.

< span lang="EN-US" style="font-family: ; mso-font-kerning: 0pt; mso-no-proof: yes">1. Attach person1 to objectContext2.

2. Attach territory1 to objectContext1.

3. Set the SalesTerritory property of person1 to territory1.

4. Call SaveChanges on both objectContext1 and objectContext2.

C.

1. Detach person1 from objectContext1.

2. Detach territory1 from objectContext2.

3. Set the SalesTerritory property of person1 to territory1.

4. Call Refresh on both objectContext1 and objectContext2.

D.

1. Attach person1 to objectContext2.

2. Detach territory1 from objectContext2.

3. Set the SalesTerritory property of person1 to territory1.

4. Call Refresh on objectContext1.

 

Correct Answer: A

 

 

 

QUESTION 209

Yo

u use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database. The application includes a table adapter named taStore, which has the following DataTable.

 

clip_image003

 

There is a row in the database that has a ProductID of 680.

 

You need to change the Name column in the row to “New Product Name”.

 

Which code segment should you use?

 

A.

Dim dt = New taStore.ProductDataTable()

Dim ca = New taStoreTableAdapters.ProductTableAdapter()

ca.Fill(dc)

Dim dv = New DataView()

dv.RowFilter = “680”

dv(0)(“Name”) = “New Product Name”

ta.Update(dt)

B.

Dim dt = New taStoreTableAdapters.ProductTableAdapter()< /font>

Dim dt = ta.GetData()

Dim row = dt.Select(“680”)

row(0)(“Name”) = “New Product Name”

ta.Update(row)

C.

Dim dt = New taStore.ProductDataTable()

Dim row = dt.NewProductRow()

row.ProductID = 680

row.Name = “New Product Name”

dt.Rows.Add(row)

D.

Dim dt = New taStore.ProductDataTable()

Dim ta = New taStoreTableAdapters.ProductTableAdapter()

ta.Fill(dt)

Dim row As taStore.ProductRow =

DirectCast(dt.Rows.Find(680), taStore.ProductRow) row.Name = “New Product Name”

ta.Update(row)

 

Correct Answer: D

Explanation:

DataRowCollecti

on.Find() Method To use the Find method, the DataTable object to which the DataRowCollection object belongs to must have at least one column designated as a primary key column. See the PrimaryKey property for details on creating a PrimaryKey column, or an array of DataColumn objects when the table has more than one primary key.

var dt = new CustomersDS.CustomersDataTable();

var ta = new CustomersDSTableAdapters.CustomersTableAdapter();

ta.Fill(dt);

CustomersDS.CustomersRow row = (CustomersDS.CustomersRow)dt.Rows.Find(4);

row.Name = ” A. Found Customer Id”;

ta.Update(row);

DataTable.Select() Method Gets an array of all DataRow objects that match the filter criteria.

To create the filterExpression argument, use the same rules that apply to the DataColumn class’s Expression property value for creating filters.

var ta = new CustomersDSTableAdapters.CustomersTableAdapter();

var dt = ta.GetData();

var row = dt.Select(“CustomerID > 2”);

row[0][“Name”] = “

B.Found Customer Id”;

ta.Update(row);

TableAdapter Overview

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

 

 

QUESTION 210

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 ADO.NET Entity Framework to manage persistence-ignorant entities. You create an ObjectContext instance named context. Then, you directly modify properties on several entities. You need to save the modified entity values to the database. Which code segment should you use?

 

A.

context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave)

B.

context.SaveChanges(SaveOptions.DetectChangesBeforeSave)

C.

context.SaveChanges(SaveOptions.None)

D.

context.SaveChanges()

 

Correct Answer: B

Explanation:

None Changes are saved without the DetectChanges or the AcceptAllChangesAfterSave() methods being called. AcceptAllChangesAfterSave After changes are saved, the AcceptAllChangesAfterSave() method is called, which resets change tracking in the ObjectStateManager. DetectChangesBeforeSave Before changes are saved, the DetectChanges method is called to synchronize the property values of objects that are attached to the object context with data in the ObjectStateManager.

SaveOptions Enumeration

http://msdn.microsoft.com/en-us/library/system.data.objects.saveoptions.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…