[Free] New Updated (October) Microsoft 70-516 Real Exam 21-30

Ensurepass

 

QUESTION 21

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You use a TableAdapter object to load a DataTable object. The DataTable object is used as the data source for a GridView control to display a table of customer information on a Web page.

 

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

 

clip_image002Load only new customer records each time the page refreshes.

clip_image002[1]Preserve existing customer records.

 

What should you do?

 

A.

Set the ClearBeforeFill property of the TableAdapter to false. Use the Fill method of the TableAdapter to load additional customers.

B.

Set the ClearBeforeFill property of the TableAdapter to false. Use the GetData method of the TableAdapter to create a new DataTable.

C.

Set the ClearBeforeFill property of the TableAdapter to true. Use the Fill method of the TableAdapter to load additional customers.

D.

Set the ClearBeforeFill property of the TableAdapter to true. Use the GetData method of the TableAdapter to create a new DataTable.

 

Correct Answer: A

Explanation:

TableAdapter.Fill Populates the TableAdapter’s associated data table with the results of the TableAdapter’s SELECT command.

TableAdapter.Update Sends changes back to the database. For more information, see How to:

Update Data Using a TableAdapter.

TableAdapter.GetData Returns a new DataTable filled with data. TableAdapter.Insert Creates a new row in the data table. For more information, see How

to: Add Rows to a DataTable.

TableAdapter.ClearBeforeFill Determines whether a data table is emptied before you call one of the Fill methods.

Table Adapter Overview

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

 

 

QUESTION 22

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

 

The application connects to a Microsoft SQL Server database.

 

The application contains an Entity Framework model that has an entity named Products.

 

You need to a write a method that accepts an input parameter named Product. The method must delete Product from the SQL Server database by using LINQ to Entities.

 

You write the following code:

 

clip_image003

 

Which code segment should you insert at line 06?

 

clip_image004

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

 

Correct Answer: B

 

 

QUESTION 23

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 changes to an order in memory an order-tracking system.

 

You need to ensure that the changes overwrite the original values of the object.

 

Which method should you call on the ObjectContext?

 

A.

AddObject

B.

AttachTo

C.

Attach

D.

ApplyCurrentValues

 

Correct Answer: D

 

 

QUESTION 24

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You use Plain Old CLR objects (POCO) to model your entities.

 

The application communicates with a Windows Communication Foundation (WCF) Data Services service.

 

You need to ensure that entities can be sent to the service as XML.

What should you do?

 

A.

Apply the virtual keyword to the entity properties

B.

Apply the [Serializable]

C.

Apply the [DataContract(lsReference = true)] attribute to the entities

D.

Apply the [DataContract(lsReference = false)] attribute to the entities

 

Correct Answer: C

Explanation:

DataContractAttribute Specifies that the type defines or implements a data contract and is serializable by a serializer, such as the DataContractSerializer. To make their type serializable, type authors must define a data contract for their type. IsReference Gets or sets a value that indicates whether to preserve object reference data.

 

 

QUESTION 25

You use Microsoft Visual Studio 2010 and the Microsoft NET Framework 4 to create an application The application connects to a Microsoft SQL Sewer database The application uses DataContexts to query the database You define a foreign key between me customers and orders tables in the database You need to ensure that when you delete a customer record, the corresponding order records are deleted You want to achieve this goal by using the minimum amount of development effort. What should you do?

 

A.

Override the Delete operation of the customer entity.

B.

Remove the foreign key between the Customers and Orders tables.

C.

Use the Execute Dynamtic Delete method of the Data Context object.

D.

Modify the foreign key between the Customers and Orders tables to enable the ON DELETE CASCADE option.

 

Correct Answer: D

Explanation:

DataContext.ExecuteDynamicDelete Method

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

 

 

QUESTION 26

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You use the ADO.NET Entity Framework to model entities. The application connects to a Microsoft SQL Server database named AdventureWorks.

 

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

 

01 using (AdventureWorksEntities context = new AdventureWorksEntities()){

 

02 ObjectQuery<SalesOrderHeader> orders =

 

03 context.SalesOrderHeader.Where(“it.CreditCardApprovalCode IS NULL”).Top(“100”);

 

04 foreach (SalesOrderHeader order in orders){

 

05 order.Status = 4;

 

06 }

 

07 try {

 

08 context.SaveChanges();

 

09 }

 

10 catch (OptimisticConcurrencyException){

 

11

 

12 }

 

13 }

 

You need to resolve any concurrency conflict that can occur. You also need to ensure that local changes are persisted to the database.

 

Which code segment should you insert at line 11?

 

A.

context.Refresh(RefreshMode.ClientWins, orders); context.AcceptAllChanges();

B.

context.Refresh(RefreshMode.ClientWins, orders); context.SaveChanges();

C.

context.Refresh(RefreshMode.StoreWins, orders); context.AcceptAllChanges();

D.

context.Refresh(RefreshMode.StoreWins, orders); context.SaveChanges();

 

Correct Answer: B

Explanation:

SaveChanges() Persists all updates to the data source and resets change tracking in the object context.

Refresh(RefreshMode, Object) Updates an object in the object context with data from the data source.

AcceptAllChanges() Accepts all changes made to objects in the object context. Refresh(RefreshMode refreshMode, Object entity) Method has the dual purpose of allowing an object to be refreshed with data from the data source and being the mechanism by which conflicts can be resolved.

ObjectContext.Refresh Method

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

 

 

QUESTION 27

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 database table named ProductCatalog as shown in the exhibit. (Click the Exhibit button.)

 

clip_image005

 

You add the following code segment to query the first row of the ProductCatalog table. (Line numbers are included for reference only.)

01 using (var cnx = new SqlConn

ection(connString))

 

02 {

 

03 var command = cnx.CreateCommand();

 

04 command.CommandType = CommandType.Text;

 

05 command.CommandText =”SELECT TOP 1 * FROM dbo.ProductCatalog”;

 

06 cnx.Open();

 

07 var reader = command.ExecuteReader();

 

08 if (reader.Read()) {

 

09 var id = reader.GetInt32(0);

 

10

 

11 reader.Close();

 

12 }

 

13 }

 

You need to read the values for the Weight, Price, and Status columns.

 

Which code segment should you insert at line 10?

 

A.

var weight = reader.GetDouble(1);

var price = reader.GetDecimal(2);

var status = reader.GetBoolean(3);

B.

var weight = reader. GetDecimal (1);

var price = reader. GetFloat (2);

var status = reader.GetByte(3);

C.

var weight = reader.GetDouble(1);

var price = reader.GetFloat(2);

var status = reader.GetBoolean(3);

D.

var weight = reader.GetFloat(1);

var price = reader.GetDouble(2);

var status = reader.GetByte(3);

 

Correct Answer: A

 

 

QUESTION 28

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.

 

You need to ensure that the application calls a stored procedure that accepts a table- valued parameter.

 

You create a SqlParameter object.

 

What should you do next?

 

A.

Set the SqlDbType of SqlPararneter to Udt

B.

Set the SqlDbType of SqlParameter to Variant.

C.

Set the Parameter Direction of SqlParameter to Output.

D.

Set the SqlDbType of SqiParameter to Structured. Set the TypeName of SqlParameter to Udt.

 

Correct Answer: D

Explanation:

SqlParameter.DbType Gets or sets the SqlDbType of the parameter. SqlParameter.TypeName Gets or sets the type name for a table-valued parameter. SqlDbType.Structured A special data type for specifying structured data contained in table- valued parameters.

Udt A SQL Server 2005 user-defined type (UDT).

 

Spatial types

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

Types of Spatial Data

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

 

 

QUESTION 29

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 MemoryStream stream = new MemoryStream() ;

 

02 var query = context.Contacts.Include(

 

“SalesOrderHeaders.SalesOrderDetails”);

 

03 var contact = query. Where(“it.LostName = Glostname”,

 

new ObjectParameter(“lastname”, 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.

var formatter = new XmlSerializer(typeof(Contact), new Type[] {

typeof(SalesOrderHeader),

typeof(SalesOrderDetail)

});

formatter.Serialize(stream contact);

B.

var formatter = new XmlSerializer(typeof(Contact));

formatter.Serialize(stream, contact);

C.

var formatter = new BinaryFormatter();

formatter.Serialize(stream, contact);

D.

var 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 30

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_image006

 

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.

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

Free VCE & PDF File for Microsoft 70-516 Real Exam

Instant Access to Fr
ee VCE Files: MCSE|MCSA|MCITP…

Instant Access to Free PDF Files: MCSE|MCSA|MCITP…