[Free] New Updated (October) Microsoft 70-516 Real Exam 211-220

Ensurepass

 

QUESTION 211

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 the ADO.NET Entity Framework to manage order data. The application makes a Web service call to obtain orders from an order-tracking system.

 

You need to ensure that the orders are added to the local data store.

 

Which method should you call on the ObjectContext?

 

A.

Attach

B.

AttachTo

C.

AddObject

D.

ApplyCurrentValues

&nb

sp;

Correct Answer: C

Explanation:

ObjectContext.AddObject() Call AddObject on the ObjectContext to add the object to the object context.

Do this when the object is a new object that does not yet exist in the data source. ObjectContext.Attach() Call Attach on the ObjectContext to attach the object to the object context.

Do this when the object already exists in the data source but is currently not attached to the context.

If the object being attached has related objects, those objects will also be attached to the object context.

Objects are added to the object context in an unchanged state. The object that is passed to the Attach method must have a valid EntityKey value. If the object does not have a valid EntityKey value, use the AttachTo method to specify the name of the entity set.

ObjectContext.AttachTo() Call AttachTo on the ObjectContext to attach the object to a specific entity set in the object context or if the object has a null (Nothing in Visual Basic) EntityKey value.

The object being attached is not required to have an EntityKey associated with it. If the object does not have an entity key, then entitySetName cannot be an empty string. ApplyCurrentValues<TEntity>() method is used to apply changes that were made to objects outside the ObjectContext, such as detached objects that are received by a Web service.

The method copies the scalar values from the supplied object into the object in the ObjectContext that has the same key.

You can use the EntityKey of the detached object to retrieve an instance of this object from the data source.

 

 

QUESTION 212

You use Microsoft Visual Studio 2010 and Microsoft ADO.NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database.

 

You use the ADO.NET LINQ to SQL model to retrieve data from the database. You use stored procedures to return multiple result sets.

 

You need to ensure that the result sets are returned as strongly typed values.

 

What should you do?

 

A.

Apply the FunctionAttribute and ResultTypeAttribute to the stored procedure function. Use the GetResult<TElement> method to obtain an enumerator of the correct type.

B.

Apply the FunctionAttribute and ParameterAttribute to the stored procedure function and directly access the strongly typed object from the results collection.

C.

Apply the ResultTypeAttribute to the stored procedure function and directly access the strongly typed object from the results collection.

D.

Apply the ParameterAttribute to the stored procedure function. Use the GetResult<TElement> method to obtain an enumerator of the correct type.

 

Correct Answer: A

Explanation:

You must use the IMultipleResults.GetResult<TElement> Method pattern to obtain an enumerator of the correct type, based on your knowledge of the stored procedure. FunctionAttribute Associates a method with a stored procedure or user-defined function in the database.

IMultipleResults.GetResult<TElement> Method

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

 

 

 

 

QUESTION 213

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 Data Definition Language (DDL) script of the database contains the following code segment.

 

CREATE TABLE [Sales].[SalesOrderHeader](

 

[SalesOrderID] [int] IDENTITY(1,1) NOT NULL,

 

[BillToAddressID] [int] NOT NULL,

 

 

CONSTRAINT [PK_SalesOrderHeader_SalesOrderID]

 

PRIMARY KEY CLUSTERED ([SalesOrderID] ASC)

 

)

 

ALTER TABLE [Sales].[SalesOrderHeader]

 

WITH CHECK ADD CONSTRAINT [FK_SalesOrderHeader_Address]

 

FOREIGN KEY([BilIToAddressID])

 

REFERENCES [Person].[Address]([AddressID])

 

You create an ADO.NET Entity Framework model.

 

You need to ensure that the entities of the model correctly map to the DDL of the database.

 

What should your model contain?

 

clip_image002

clip_image003

clip_image004

clip_image005

< font face="Arial"> 

A.

Exhibit A

B.

Exhibit B

C.

Exhibit C

D.

Exhibit D

Correct Answer: A

 

 

QUESTION 214

HOTSPOT

You create an Entity Data Model (EDM) named ModelContoso.

 

You need to generate a Transact-SQL script to create a database to store ModelContoso. The solution must ensure that table names are prefixed automatically with TBL_.

 

Which property of ModelContoso should you modify?

 

To answer, select the appropriate property in the answer area.

 

clip_image007

 

Correct Answer:

clip_image009

 

 

QUESTION 215

DRAG DROP

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 have the following stored procedure:

 

clip_image010

 

You need to return a list of customers who match a given order date. The solution must meet the following requirements:

 

Use a forward-only data object.

 < /p>

Use a read-only data object.

 

What should you do?

 

To answer, drag the appropriate code segments to the correct locations. Each code segment 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_image012

 

Correct Answer:

clip_image014

 

 

QUESTION 216

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

 

The application connects to two different Microsoft SQL Server 2008 database servers named Serverl and Server2.

 

A string named sqllcontains a connection string to Serverl. A string named sql2contains a connection string to Server2.

 

01 Using scope As New

 

02

03 Using cnl As New SqlConnection(sqll)

 

04 Try

 

05

 

06 Catch ex As Exception

 

07 End Try

 

08 End Using

 

09 scope.Complete()

 

10 End Using

 

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

 

clip_image016There is a SqlConnection named cn2 that uses sql2.

clip_image016[1]The co

mmands that use cnl are initially enlisted as a lightweight transaction.

clip_image016[2]The cn2 SqlConnection is enlisted in the same TransactionScope only if commands executed by cnl do not throw an exception.

 

What should you do?

 

A.

Insert the following code segment at line 02.

Transacti onScope (TransactionScopeOption. RequiresNew)

Insert the following code segment at line 05.

cnl. Open ()

Using cn2 As New SqlConnection(sql2)

Try

cn2 .OpenO Catch ex As Excepcion

End Try

End Using

B.

Insert the following code segment at line 02.

TransaccionScope(TransaccionScopeOption.Suppress)

Insert the following code segment at line 05.< /font>

cnl .Open()

Using cn2 As New SqlConnection(sql2)

Try

cn2-Open()

Catch ex As Exception

End Try

End Using

C.

Insert the following code segment at line 02.

TransactionScope(TransactionScopeOption.Suppress)

Insert the following code segment at line 05.

Using cn2

As New

SqlConnection(sql2)

Try

cn2 . Open()

cnl .Open ()

Catch ex As Exception E

nd Try

End Using

D.

Insert the following code segment at line 02.

TransactionScope(TransactionScopeOption.RequiresNeW)

Insert the following code segment at line 05.

Using cn2 As New SqlConnection(sql2)

Try

cn2 .Open ( )

cnl. Open {}

Catch ex As Exception

End Try

End Using

 

Correct Answer: B

Explanation:

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

 

 

QUESTION 217

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 Data Contexts to query the database.

 

The application meets the following requirements:

 

clip_image016[3]Stores customer data offline

< a href="http://www.pass-exams.com/wp-content/uploads/2015/10/clip_image01641.gif">clip_image016[4]Allows users to update customer records while they are disconnected tram the server

clip_image016[5]Enables online changes to be submitted back to the SQL Server by using the Data Context 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 Submit Changes method of the Data Context object and catch Sql Exceptions

B.

Add a try/catch statement around calls to the Submit Changes method of the Data Context object and catch Change context Exceptions

C.

Override the Update operation of the Data Context object Call the Executedynamic Update method to generate the update SQL

D.

Call the Submit Changes method of the Data Context object, Pass System Data L’nq ConflictMode Continue OnConflict 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 218

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 conceptual schema definition language (CSDL) file contains the following XML fragment.

 

<EntityType Name=”Contact”>

 

 

<Property Name=”EmailPhoneComplexProperty”

 

Type=”AdventureWorksModel.EmailPhone”

 

Nullable=”false” />

 

</EntityType>

 

 

<ComplexType Name=”EmailPhone”>

 

<Property Type=”String” Name=”EmailAddress”

 

MaxLength=”50″ FixedLength=”false”

 

Unicode=”true” />

 

<Property Type=”String” Name=”Phone” MaxLength=”25″

 

FixedLength=”false” Unicode=”true” />

 

</ComplexType>

 

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

 

01 Using conn As New EntityConnection(“name=AdvWksEntities”)

 

02 conn.Open()

 

03 Dim esqlQuery As String = “SELECT VALUE contacts FROM” &

 

04 ” AdvWksEntities.Contacts AS contacts” &

 

05 ” WHERE contacts.ContactID == 3″

 

06 Using cmd As EntityCommand = conn.CreateCommand()

 

07 cmd.CommandText = esqlQuery

 

08 Using rdr As EntityDataReader = cmd.ExecuteReader()

09 While rdr.Read()

 

10

 

11 End While

 

12 End Using

 

13 End Using

 

14 conn.Close()

 

15 End Using

 

You need to ensure that the code returns a reference to a ComplexType entity in the model named EmailPhone.

 

Which code segment should you insert at line 10?

 

A.

Dim FldIdx As Integer = 0

Dim key As EntityKey = TryCast(record.GetValue(FldIdx), EntityKey)

For Each keyMember As EntityKeyMember In key.EntityKeyValues

Return keyMember.Key + ” : ” + keyMember.Value

Next

B.

Dim record As IExtendedDataRecord = TryCast(rdr(“EmailPhone”),

IExtendedDataRecord)

Dim FldIdx As Integer = 0

Return record.GetValue(FldIdx)

C.

Dim nestedRecord As DbDataRecord = TryCast(rdr(“EmailPhoneComplexProperty”),

DbDataRecord) Return nestedRecord

D.

Dim fieldCount As Integer = rdr(“EmailPhone”).DataRecordInfo.FieldMetadata.Count

Dim FldIdx As Integer = 0

While FldIdx < fieldCount

rdr.GetName(FldIdx)

If rdr.IsDBNull(FldIdx) = False Then

Return rdr(“EmailPhone”).GetValue(FldIdx).ToString()

End If

System.Math.Max(System.Threading.Interlocked.Increment(FldIdx), FldIdx – 1)

End While

 

Correct Answer: C

 

 

QUESTION 219

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the ADO.NET Entity Framework to model entities. You create an entity model as shown in the following diagram.

 

You need to ensure that all Person entities and their associated EmailAddresses are loaded.

 

clip_image017

 

Which code segment should you use?

 

A.

Dim people = contexc.People.Include (“EmailAddresses”).ToList()

B.

Dim people = contexc.People.Except

(New ObjectQuery(Of Person)(“Person.EmailAddresses”, context)).ToList()

C.

Dim people = context.People.Except

(New ObjectQuery(Of Person)(“EmailAddresses”/ context)).ToList()

D.

Dim people = context.People.Include (“Person.EmailAddresses”).ToList()

 

Correct Answer: A

Explanation:

CHAPTER 6 ADO.NET Entity Framework

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

Lazy Loading vs. Explicit Loading vs. Eager Loading (page 384)

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

 

 

QUESTION 220

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 define a Category class by writing the following code segment. (Line numbers are included for reference only.)

 

01 public class Category

 

02 {

 

03 public int CategoryID { get; set; }

 

04 public string CategoryName { get; set; }

 

05 public string Description { get; set; }

 

06 public byte[] Picture { get; set; }

07

 

08 }

 

You need to add a collection named Products to the Category class. You also need to ensure that the collection supports deferred loading. Which code segment should you insert at line 07?

 

A.

public static List <Product> Products { get; set; }

B.

public virtual List <Product> Products { get; set; }

C.

public abstract List <Product> Products { get; set; }

D.

protected List <Product> Products { get; set; }

 

Correct Answer: B

Explanation:

One of the requirements for lazy loading proxy creation is that the navigation properties must be declared virtual (Overridable in Visual Basic). If you want to disable lazy loading for only some navigation properties, then make those properties non-virtual.

Loading Related Objects (Entity Framework)

http://msdn.miFree 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… crosoft.com/en-us/library/gg715120(v=vs.103).aspx