[Free] New Updated (October) Microsoft 70-516 Real Exam 161-170

Ensurepass
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…

QUESTION 161

You use Microsoft .NET Framework 4 to develop an application that uses Entity Framework. The application includes the following Entity SQL (ESQL) query.

 

SELECT VALUE product

 

FROM AdventureHorksEntities.Products As product

 

ORDER BY product.ListPrice

 

You need to modify the query to support paging of the query results.

 

Which query should you use?

 

A.

SELECT TOP Stop VALUE product

FROM AdventureHorksEntities.Products AS product ORDER BY product.ListPrice SKIP @skip

B.

SELECT VALUE product

FROM AdventureHorksEntities.Products AS product ORDER BY product.ListPrice SKIP @skip LIMIT @limit

C.

SELECT SKIP @skip VALUE product

FROM AdventureHorksEntities.Products AS product ORDER BY product.ListPrice LIMIT @limit

D.

SELECT SKIP @skip TOP Stop VALUE product

FROM AdventureHorksEntities.Products AS product ORDER BY product.ListPrice

 

Correct Answer: B

Explanation:

Entity SQL Reference

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

How to: Page Through Query Results

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

 

 

QUESTION 162

You use Microsoft .NET Framework 4 to develop an application that uses WCF Data Services to persist entities from the following Entity Data Model.

 

clip_image001

 

You create a new Blog instance named newBlog and a new Post instance named newPost as shown in the following code segment. (Line numbers are included for reference only.)

 

01 Dim newBlog As Blog = New Blog()

 

02 Dim newPost As Post = New Post ()

 

03 —

 

04 Dim serviceUri As Uri – New Uri(“–“)

 

05 Dim context As BlogsEntities =

 

06 New BlogsEntities (serviceUri) 07

 

You need to ensure that newPost is related to newBlog through the Posts collection property and that newPost and newBlog are sent to the service.

 

Which code segment should you insert at line 07?

 

A.

newBlog.Posts.Add(newPost)

context.AttachTo(“Blogs”, newBlog)

context.AttachTo(“Posts”, newPost)

context.SaveChanges(SaveChangesOptions.Batch)

B.

newBlog.Posts.Add(newPost)

context.UpdateObject(newBlog)

context.UpdateObject(newPost)

context.SaveChanges(SaveChangesOpt ions.Batch)

C.

newBlog.Posts.Add(newPost)

context.AddToBlogs(newBlog)

context.AddToPosts(newPost)

context.SaveChanges(SaveChangesOpt ions.Batch)

D.

context.AttachLink(newBlog, “Posts”, newPost)

context.SaveChanges(SaveChangesOptions.Batch)

 

Correct Answer: A

Explanation:

Attaching and Detaching objects

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

 

 

QUESTION 163

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

 

You write a method named ValidatePostalCode to validate the postal code for the application.

 

You need to ensure that the ValidatePostalCode method is called before the PostalCode property set method is completed and before the underlying value has changed.

 

Which code segment should you place in the entity’s partial class?

 

A.

Public Property ValidatedPostalCode As String

Get

Return _PostalCode

End Get

Set(ByVal value As String)

PostalCode – StructuralObject.SetValidValue( _

“ValidatePostalCode”, False)

End Set

End Property

B.

Private Sub OnPostalCodeChanging(ByVal value As String)

ValidatePostalCode(value)

End Sub

C.

Public Property ValidatedPostalCode As String

Get

Return _PostalCode

End Get

Set(ByVal value As String)

ValidatePostalCode(value) _

PostalCode = value

End Set

End Property

D.

Private Sub OnPostalCodeChanged(ByVal value As String)

PostalCode = GetValidValue(Of String)

(value, “ValidatePostalCode”, False, True)

End Sub

 

Correct Answer: B

Explanation:

Another area of extensibility is with the partial methods created on each entity type. There is a pair of partial methods called OnXxxChanging and OnXxxChanged for each property, in which Xxx is the name of the property. The OnXxxChanging method executes before the property has changed, and the OnXxxChanged method executes after the property has changed. To implement any of the partial methods, create a partial class and add the appropriate partial method with implementation code.

CHAPTER 6 ADO.NET Entity Framework

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

Partial Classes and Methods(page 390)

How to: Execute Business Logic During Scalar Property Changes

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

 

 

QUESTION 164

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the Entity Framework. The application defines the following Entity Data Model.

 

Within the .edmx file, the following function is defined.

 

<Functlon Name-“Round” RetuEnType-“Decimal”>

 

<Parametec Name-“val” Type-“Decimal” />

 

<DefiningExpression> CAST(val As Edm.Int32)

 

</DefiningExpression>

 

</Function>

 

The application includes the following LINQ query.

 

Dim query = From detail In context.SalesOrderDetails Select detail.LineTotal.Round()

 

You need to ensure that the Round function executes on the database server when the query is executed.

 

Which code segment should you use?

 

A.

Module DecimalHelper

<EdmFunctlon(“SqlServer”, “Round”)>

<Extension()>

Public Function Round(ByVal Amt As Decimal) As Decimal

Throw New NotSupportedException() End Function

End Module

B.

Module DecimalHelper

<EdmFunction(“Edm”, “Round”)>

<Extension()>

Public Function Round(ByVal Amt As Decimal) As Decimal

Throw New NotSupportedException() End Function

End Module

C.

Module DecimalHelper

<Extension()> Public Function Round( ByVal input As Decimal) As SqlDecimal Return

SqlDecimal.Round(input/ 0) End Function

End Module

D.

Module PecimalHelper

<Extension()>

Public Function Round(ByVal Input As Decimal) As Decimal

Return Convert.ToDeclroal(Convert.ToInt32(Input)) End Function

End Module

 

Correct Answer: B

Explanation:

EdmFunctionAttribute Class

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

How to: Call Model-Defined Functions in Queries

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

The model-defined function has been created in the conceptual model, but you still need a way to connect your code to it.

To do so, add a function into your C# code, which will have to be annotated with the EdmFunctionAttribute attribute.

This function can be another instance method of the class itself, but best practice is to create a separate class and define this method as static.

 

 

QUESTION 165

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 166

You use Microsoft .NET Framework 4 to develop an application that exposes a WCF Data Services endpoint.

 

The endpoint uses an authentication scheme that requires an HTTP request that has the following header format.

 

GET /OData.svc/Products(l)

 

Authorization: WRAP access_token “123456789”

 

You add the following method to your DataService implementation.

 

Protected Overrides Sub OnStartProcessingRequest( ByVal args As System.Data.Services.ProcessRequestArgs)

 

 

End Sub

 

You need to ensure that the method retrieves the authentication token.

 

Which line of code should you use?

 

A.

Dim token As String =

args.OperationContext.RequestHeaders(“Authorization”)

B.

Dim token As String =

args.OperationContext.RequestHeaders(“URAP access token”)

C.

Dim token As String =

args.OperationContext.ResponseHeaders(“WRAP access token”)

D.

Dim token As String =

args.OperationContext.ResponseHeaders(“Authorization”)

 

Correct Answer: A

Explanation:

OData and Authentication – OAuth WRAP

http://blogs.msdn.com/b/astoriateam/archive/2010/08/19/odata-and-authentication-part-8- oauth-wrap.aspx

 

 

QUESTION 167

You use Microsoft .NET framework 4 to develop an application that connects to a Microsoft SQL Serve 2008database named AdventureWorksLT. The database resides on an instance named INSTA on a server named SQL01. You need to configure the application to connect to the database.

 

A.

Data Source=SQL01; Initial Catalog=INSTA;

Integrated Security=true;

Application Name=AdventureWorksLT;

B.

Data Source=SQL01;

Initial Catalog=AdventureWorksLT;

Integrated Security=true;

Application Name=INSTA;

C.

Data Source=SQL01INSTA;

Initial Catalog=AdventureWorksLT;

Integrated Security=true;

D.

Data Source=AdventureWorksLT;

Initial Catalog=SQL01INSTA;

Integrated Security=true;

 

Correct Answer: C

Explanation:

CHAPTER 2 ADO.NET Connected Classes

Lesson 1: Connecting to the Data Store

Configuring an SQL Server Connection String (page 70-71)

 

 

QUESTION 168

You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 200B database.

 

You need to ensure that the application connects to the database server by using SQL Server authentication.

 

Which connection string should you use?

 

A.

SERVER=MyServer; DATABASE=AdventureUorks;

Integrated Security=SSPI; UID=sa; PWD=secret

B.

SERVER-MyServer; DATABASE-AdventureWorks;

UID=sa; PWD=secret

C.

SERVER-HyServec; DATABASE-AdventureUocks;

Integrated Security=false

D.

SERVER-HyServer; DATABASE-AdventureWorks;

Trusted Connection”true

 

Correct Answer: B

Explanation:

SQL Server autentification using the passed-in user name and password. User ID, Uid, User, Password, Pwd Connection String Syntax (ADO.NET)

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

 

 

QUESTION 169

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 170

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to enhance an existing application to use the Entity Framework. The classes that represent the entities in the model are Plain Old CLR Object (POCO) classes.

 

You need to connect the existing POCO classes to an Entity Framework context.

 

What should you do?

 

A.

1. Generate a MetadataWorkspace and create an ObjectContext for the model.

2. Disable proxy object creation on the ContextOptions of the ObjectContext.

3. Enable lazy loading on the ContextOptions of the ObjectContext.

B.

1. Generate a MetadataWorkspace and create an ObjectContext for the model.

2. Create an ObjectSet for the POCO classes.

3. Disable proxy object creation on the ContextOptions of the ObjectContext.

C.

1. Generate an Entity Data Model for the POCO classes.

2. Create an ObjectSet for the POCO classes.

3. Disable proxy object creation on the ContextOptions of the ObjectContext.

4. Enable lazy loading on the ContextOptions of the ObjectContext.

D.

1. Generate an Entity Data Model for the POCO classes.

2. Create an ObjectSet for the POCO classes.

3. Set Code Generation Strategy on the Entity Data Model to none.

4. Create an ObjectContext for the model.

 

Correct Answer: D