[Free] New Updated (October) Microsoft 70-516 Real Exam 221-230

Ensurepass

 

QUESTION 221

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 Entity Framework to access data.

 

You need to use Entity SQL to query data from an object of type ObjectContext.

 

Which method should you use first?

 

A.

ExecuteStoreCommand

B.

ExecuteStoreQuery

C.

CreateObject

D.

CreateQuery

 

Correct Answer: D

 

 

QUESTION 222

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application that uses the Entity Framework. Entity types in the model are generated by the Entity Data Model generator tool (EdmGen.exe).

 

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

 

01 Dim stream As MemoryStream = New HemoryStream()

 

02 Dim query = context.Contacts.Include(

 

“SalesOrderHeaders.SaiesOrderDetails”)

 

03 Dim contact = query.Where(“it.LastName – Slostname”,

 

New ObjectParameter(“lastnarae”, lastName)).First()

04

 

You need to serialize the contact and all of its related objects to the MemoryStream so that the contact can be deserialized back into the model.

 

Which code segment should you insert at line 04?

 

A.

Dim formatter – New XmlSerializer(GetType(Contact),

New Type() (GetType(SalesOrderHeader),

GetType(SalesOrderDetail)})

formatter-Serialize(stream, contact)

B.

Dim formatter = New BinaryFormatter()

formatter.Serialize(stream, contact)

C.

Dim formatter = New XmlSerializer(GetType(Contact))

formatter.Serialize(stream, contact)

D.

Dim formatter = New SoapFormatter()

formatter-Serialize(stream, contact)

 

Correct Answer: A

Explanation:

public XmlSerializer(Type type, Type[] extraTypes) Initializes a new instance of the System.Xml.Serialization.XmlSerializer class that can serialize objects of the specified type into XML documents, and deserialize XML documents into object of a specified type. If a property or field returns an array, the extraTypes parameter specifies objects that can be inserted into the array.

type:

The type of the object that this System.Xml.Serialization.XmlSerializer can serialize.extraTypes:

A System.Type array of additional object types to serialize.

XmlSerializer Constructor (Type, Type[])

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

 

 

QUESTION 223

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application retrieves data from a Microsoft SQL Server 2008 database named AdventureWorks. The AdventureWorks.dbo.ProductDetails table contains a column named ProductImages that uses a varbinary(max) data type.

 

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

 

01 Dim reader As SqlDataReader = command.ExecuteReader(

 

02

 

03 )

 

04 While reader.Read()

 

05 pubID = reader.GetString(0)

 

06 …

 

07 stream = New FileStream()

 

08 writer = New BinaryWriter(stream)

09 startIndex = 0

 

10 retval = reader.GetBytes(1, startIndex, outByte, 0, bufferSize)

 

11 …

 

12 While retval = bufferSize

 

13 End While

 

14 writer.Write(outByte, 0, DirectCast(retval, Integer) – 1)

 

15 writer.Flush()

 

16 writer.Close()

 

17 stream.Close()

 

18 End While

 

You need to ensure that the code supports streaming data from the ProductImages column.

 

Which code segment should you insert at line 02?

 

A.

CommandBehavior.[Default]

B.

CommandBehavior.KeyInfo

C.

CommandBehavior.SingleResult

D.

CommandBehavior.SequentialAccess

 

Correct Answer: D

Explanation:

Default

The query may return multiple result sets. Execution of the query may affect the database state.

Default sets no CommandBehavior flags, so calling ExecuteReader(CommandBehavior.Default) is functionally equivalent to calling ExecuteReader().

KeyInfo The query returns column and primary key information. When KeyInfo is used for command execution, the provider will append extra columns to the result set for existing primary key and timestamp columns.

SingleResult The query returns a single result set.

SequentialAccess Provides a way for the DataReader to handle rows that contain columns with large binary values.

Rather than loading the entire row, SequentialAccess enables the DataReader to load data as a stream.

You can then use the GetBytes or GetChars method to specify a byte location to start the read operation, and a limited buffer size for the data being returned.

CommandBehavior Enumeration

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

 

 

 

 

 

 

 

 

QUESTION 224

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server 2008 database. The database includes a table that contains information about all the employees. The database table has a field named EmployeeType that identifies whether an employee is a Contractor or a Permanent employee.

 

You declare the Employee entity base type.

 

You create a new Association entity named Contractor that inherits the Employee base type.

 

You need to ensure that all Contractors are bound to the Contractor class.

 

What should you do?

 

A.

Modify the .edmx file to include the following line of code. <Condition ColumnName=”EmployeeType” Value=”Contractor” />

B.

Use the Entity Data Model Designer to set up a referential constraint between the primary key of the Contractor class and EmployeeType.

C.

Modify the .edmx file to include the following line of code. <NavigationProperty Name=”Type” FromRole=”EmployeeType” ToRole=”Concraccor” />

D.

Use the Entity Data Model Designer to set up an association between the Contractor class and EmployeeType.

 

Correct Answer: A

Explanation:

<Association Name=”FK_OrderDetails_Orders1″>

<End Role=”Orders” Type=”StoreDB.Store.Orders” Multiplicity=”1″>

<OnDelete Action=”Cascade” />

</End>

<End Role=”OrderDetails” Type=”StoreDB.Store.OrderDetails” Multiplicity=”*” />

<ReferentialConstraint>

<Principal Role=”Orders”>

<PropertyRef Name=”ID” />

</Principal>

<Dependent Role=”OrderDetails”>

<PropertyRef Name=”OrderId” />

</Dependent>

</ReferentialConstraint>

</Association>

 

 

QUESTION 225

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_image001

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

 

01 Shared Sub Insert()

 

02

 

03 Dim dc As NorthuindDataContext –

 

New NorthwindDataContext (“…”)

 

04 Dim neuCustomer As Customer = New Customer()

 

05 newCustomer.Firstname = “Todd”

 

06 newCustomer.Lastname = “Meadows”

 

07 newCustomer.Email = “tmeadous@contoso.com”

 

08

 

09 dc.SubmitChanges()

 

10 End Sub

 

A product named Bike Tire exists in the Products table. The new customer orders the Bike Tire product.

 

You need to ensure that the correct product is added to the order and that the order is associated with the new customer.

 

Which code segment should you insert at line 08?

 

A.

Dim newProduct As Product = New Produce()

newProduct.ProductName = “Bike Tire”

Dim newOrder As Order = New Order()

newOrder.Product = newProduct

newCustomer.Orders.Add(newOrder)

B.

Dim newProduct As Product = New Product()

newProduct.ProductName = “Bike Tire”

Dim newOrder As Order = New Order()

newOrder.Product = newProduct

C.

Dim newOrder As Order = New Order()

newOrder.Product = (From p in dc.Products

Where p.ProductName = “Bike Tire”

Select p) .First ()

D.

Dim newOrder As Order = New Order ()

newOrder.Product = (From p in dc.Products

Where p.ProductName = “Bike Tire”

Select p) .First () newCustomer.Orders.Add(newOrder)

 

Correct Answer: D

 

 

 

 

QUESTION 226

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

 

The application uses a Microsoft ADO.NET SQL Server managed provider. When a connection fails, the application logs connection information, including the full connection string. The information is stored as plain text in a .config file.

 

You need to ensure that the database credentials are secure.

 

Which connection string should you add to the .config file?

 

A.

Data Source=myServerAddress; Initial Catalog=myDataBase; Integrated Security=SSPI; Persist Security Info=false;

B.

Data Source=myServerAddress; Initial Catalog=myDataBase; Integrated Security=SSPI; Persist Security Info=true;

C.

Data Source=myServerAddress; Initial Catalog=myDataBase; User Id = myUsername; Password = myPassword; Persist Security Info=false;

D.

Data Source=myServerAddress; Initial Catalog=myDataBase; User Id = myUsername; Password = myPassword; Persist Security Info=true;

 

Correct Answer: A

Explanation:

Persist Security Info

Default: ‘false’

When set to false or no (strongly recommended), security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. Resetting the connection string resets all connection string values including the password.

Recognized values are true, false, yes, and no.

 

 

QUESTION 227

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_image002

 

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_image004

 

Correct Answer:

clip_image006

 

 

QUESTION 228

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 deploy an application to a production server. The application uses the model and mapping files that are deployed as application resources.

 

You need to update the conceptual model for the application on the production server.

 

What should you do?

 

A.

Copy the updated .edmx file to the production server.

B.

Copy the updated .csdl file to the production server.

C.

Copy the updated .ssdl file to the production server.

D.

Recompile the application and redeploy the modified assembly file.

 

Correct Answer: D

 

 

QUESTION 229

DRAG DROP

You plan to generate the following Transact-SQL script from an Entity Data Model (EDM) by using the Entity Framework Designer:

 

clip_image007

You create an entity named Employee.

 

You need to identify the data types for the properties of the Employee entity.

 

What should you identify?

 

To answer, drag the appropriate data types to the correct statements. Each data type 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_image008

 

Correct Answer:

clip_image009

 

 

 

 

 

 

 

 

 

QUESTION 230

You use Microsoft Visual Studio 2010 and Microsoft NET Framework 4 to create an application. You use the ADONET Entity Data Model (EDM) to define a Customer entity.

 

You need to add a new Customer to the data store without setting all the customer’s properties.

 

What should you do?

 

A.

Call the Create method of the Customer object

B.

Call the CreateObject method of the Customer object

C.

Override the Create method for the Customer object

D.

Override the Save Changes method for the Customer object

 

Correct Answer: B

Explanation:

CreateObject<T> Creates and returns an instance of the requested type.

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…