[Free] New Updated (October) Microsoft 70-516 Real Exam 51-60

Ensurepass

 

QUESTION 51

You use the Microsoft .NET Framework 4 Entity Framework to develop an application that contains an Entity Data Model for the following database tables.

 

clip_image001

 

You need to ensure that the entity that is mapped to the ContentTypeDerived table derives from the entity that is mapped to the ContentTypeBase table.

 

What should you do?

A.

Use a Table-Per-Type mapping method.

B.

Use a Table-Per-Hierarchy mapping method.

C.

Create a function import for each entity.

D.

Create a complex type for each entity.

 

Correct Answer: A

 

 

QUESTION 52

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application. You use the Entity Framework Designer to create an Entity Data Model from an existing database by using the Generate from database wizard.

 

The model contains an entity type named Product. The Product type requires an additional property that is not mapped to a database column.

 

You need to add the property to Product.

 

What should you do?

 

A.

Add the property in the generated class file, and select Run Custom Tool from the solution menu.

B.

Add the property in a partial class named Product in a new source file.

C.

Create a complex type with the name of the property in the Entity Framework Designer.

D.

Create a function import with the name of the property in the Entity Framework Designer.

 

Correct Answer: B

 

 

QUESTION 53

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 create classes by using LINQ to SQL based on the records shown in the exhibit. (Click the Exhibit button.)

 

clip_image002

 

You need to create a LINQ query to retrieve a list of objects that contains the OrderID and CustomerID properties.

 

You need to retrieve the total price amount of each Order record.

 

What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

 

A.

from details in dataContext.Order_Detail

group details by details.OrderID into g

join order in dataContext.Orders on g.Key equals order.OrderID

select new {

OrderID = order.OrderID, CustomerID = order.CustomerID,

TotalAmount = g.Sum(od => od.UnitPrice * od.Quantity)

}

B.

dataContext.Order_Detail.GroupJoin(dataContext.Orders,

d => d.OrderID,

o => o.OrderID,

(dts, ord) => new {

OrderID = dts.OrderID,

CustomerID = dts.Order.CustomerID,

TotalAmount = dts.UnitPrice * dts.Quantity

}

)

C.

from order in dataContext.

Orders group order by order.OrderID into g

join details in dataContext.Order_Detail on g.Key equals details.OrderID

select new {

OrderID = details.OrderID,

CustomerID = details.Order.CustomerID,

TotalAmount = details.UnitPrice * details.Quantity

}

D.

dataContext.Orders.GroupJoin(dataContext.Order_Detail,

o => o.OrderID,

d => d.OrderID.

(ord, dts) => new {

OrderID = ord.OrderID,

CustomerID = ord.CustomerID,

TotalAmount = dts.Sum(od => od.UnitPrice * od.Quantity) }

)

 

Correct Answer: AD

Explanation:

Alterantive

A.This is an Object Query. It looks at the Order Details EntitySet and creating a group g based on OrderID.

* The group g is then joined

with Orders EntitySet based on g.Key = OrderID

* For each matching records a new dynamic object containing OrderID, CustomerID and TotalAmount is created.

* The dynamic records are the results returned in an INumerable Object, for later processing

Alterantive D.This is an Object Query. The GroupJoin method is used to join Orders to OrderDetails.

 

Parameters for GroupJoin:

 

1. An Order_Details EntitySet

2. Order o (from the Orders in the Orders Entity Set, picking up Order_id from both Entity Sets)

3. Order_ID from the first Order_Details record from the OD EnitySet

4. Lamda Expression passing ord and dts (ord=o, dts=d) The body of the Lamda Expression is working out the total and Returning a Dynamic object as in A.

 

 

 

 

QUESTION 54

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 model entities. The database includes objects based on the exhibit. (Click the Exhibit button.)

 

clip_image004

 

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

 

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

 

02

 

03 }

 

You need to retrieve a list of all Products from todays sales orders for a specified customer.

 

You also need to ensure that the application uses the minimum amount of memory when retrieving the list.

 

Which code segment should you insert at line 02?

 

A.

Contact customer = context.Contact.Where(“it.ContactID = @customerId”, new ObjectParameter(“customerId”, customerId)).First(); customer.SalesOrderHeader.Load();

foreach (SalesOrderHeader order in customer.SalesOrderHeader) {

order.SalesOrderDetail.Load();

if (order.OrderDate.Date == DateTime.Today.Date)

{

foreach (SalesOrderDetail item in order.SalesOrderDetail) {

Console.WriteLine(String.Format(“Product: {0} “, item.ProductID)); }

}

}

B.

Contact customer = context.Contact.Where(“it.ContactID = @customerId”, new ObjectParameter(“customerId”, customerId)).First(); customer.SalesOrderHeader.Load();

foreach (SalesOrderHeader order in customer.SalesOrderHeader){ if (order.OrderDate.Date == DateTime.Today.Date)

{

order.SalesOrderDetail.Load();

foreach (SalesOrderDetail item in order.SalesOrderDetail) {

Console.WriteLine(String.Format(“Product: {0} “, item.ProductID)); }

}

}

C.

Contact customer = (from contact in context.Contact.Include(“SalesOrderHeader”) select contact).FirstOrDefault();

foreach (SalesOrderHeader order in customer.SalesOrderHeader) {

order.SalesOrderDetail.Load();

if (order.OrderDate.Date == DateTime.Today.Date){ foreach (SalesOrderDetail item in order.SalesOrderDetail) {

Console.WriteLine(String.Format(“Product: {0} “, item.ProductID)); }

}

}

D.

Contact customer = (from contact in

context.Contact.Include(“SalesOrderHeader.SalesOrderDetail”) select contact).FirstOrDefault();

foreach (SalesOrderHeader order in customer.SalesOrderHeader)

{

if (order.OrderDate.Date == DateTime.Today.Date)

{

foreach (SalesOrderDetail item in order.SalesOrderDetail) {

Console.WriteLine(String.Format(“Product: {0} “, item.ProductID)); }

}

}

 

Correct Answer: B

Explanation:

A & C check the Order date after Order Detail, so we are retrieving more Order details than necessary.

D is calling a Function (using eager loading) for the First Contact record only, so does not meet the requirements.

 

 

QUESTION 55

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

 

The application includes a SqlConnection named conn and a SqlC

ommand named cmd.

 

You need to create a transaction so that database changes will be reverted in the event that an exception is thrown.

 

Which code segment should you use?

 

A.

var transaction = conn.BeginTransaction();

cmd.Transaction = transaction;

try

{

transaction.Commit();

}

catch

{

transaction.Rollback();

}

B.

var transaction = conn.BeginTransaction();

cmd.Transaction = transaction;

try

{

transaction.Commit();

}

catch

{

transaction.Dispose();

}

C.

var transaction = conn.BeginTransaction();

cmd.Transaction = transaction;

try

{

}

catch

{

transaction.Commit();

}

D.

var transaction = conn.BeginTransaction();

cmd.Transaction = transaction;

try

{

transaction.Rollback();

}

catch

{

transaction.Dispose ();

}

 

Correct Answer: A

 

 

QUESTION 56

You 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_image005

 

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.

var dt = new taStore.ProductDataTable();

var ta = new taStoreTableAdapters.ProductTableAdapter(); ta.Fill(dt);

taStore.ProductRow row = (taStore.ProductRow)

dt.Rows.Find(680) ;

row.Name = “New Product Name”;

ta.Update(row);

B.

var ta = new taStoreTableAdapters.ProductTableAdapter(); var dt = ta.GetData();

var row = dt.Select(“680”) ;

row[0][“Name”] = “New Product Name”;

ta.Update(row);

C.

var dt = new taStore.ProductDataTable();

var ta = new taStoreTableAdapters.ProductTableAdapter(); ta.Fill(dt);

var dv = new DataView();

dv.RowFilter = “680”;

dv[0][“Name”] = “New Product Name”;

ta.Update(dt);

D.

var dt = new taStore.ProductDataTable();

var row = dt,NewProductRow();

row.ProductID = 680;

row.Name =

“New Product Name”;

dt.Rows.Add(row) ;

 

Correct Answer: A

Explanation:

DataRowCollection.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 Cust

omer Id”;

ta.Update(row);

TableAdapter Overview

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

 

 

QUESTION 57

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Communication Foundation (WCF) Data Services service. You deploy the data service to the following URL: http://contoso.com/Northwind.svc.

 

You need to update the City property of the Customer record that has its ID value as 123.

 

You also need to preserve the current values of the remaining properties.

Which HTTP request should you use?

 

A.

PUT /Northwind.svc/Customers(123)

Host: contoso.com

Content-Type: application/json

{

City: ‘Seattle’

}

B.

PUT /Northwind.svc/Customers(123)

Host: contoso.com

Accept: application/json

{

City: ‘Seattle’

}

C.

MERGE /Northwind.svc/Customers(123)

Host: contoso.com

Content-Type: application/json

{

City: ‘Seattle’

}

D.

MERGE /Northwind.svc/Customers(123)

Host: contoso.com

Accept: application/json

{

City: ‘Seattle’

}

 

Correct Answer: C

Explanation:

HTTP Actions

OData supports the following HTTP actions to perform create, read, update, and delete operations on the entity data that the addressed resource represents:

HTTP GET – This is the default action when a resource is accessed from a browser. No payload is supplied in the request message, and a response method with a payload that contains the requested data is returned.

HTTP POST – Inserts new entity data into the supplied resource. Data to be inserted is supplied in the payload of the request message.

The payload of the response message contains the data for the newly created entity. This includes any autogenerated key values.

The header also contains the URI that addresses the new entity resource.

HTTP DELETE – Deletes the entity data that the specified resource represents. A payload is not present in the request or response messages.

HTTP PUT – Replaces existing entity data at the requested resource with new data that is supplied in the payload of the request message.

HTTP MERGE – Because of inefficiencies in executing a delete followed by an insert in the data source just to change entity data, OData introduces a new HTTP MERGE action. The payload of the request message contains the properties that must be changed on the addressed entity resource. Because HTTP MERGE is not defined in the HTTP specification, it may require additional processing to route a HTTP MERGE request through non-OData aware servers.

 

Accessing and Changing Data Using REST Semantics

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

HTTP header fields

http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

Accept Content-Types that are acceptable

Content-Type The mime type of the body of the request (used with POST and PUT requests)

A Guide to Designing and Building RESTful WebServices with WCF 3.5

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

 

 

QUESTION 58

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.microsoft.com/en-us/library/gg715120(v=vs.103).aspx

 

 

QUESTION 59

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 need to ensure that the model and mapping files are not deployed as application resources.

 

What should you do?

 

A.

Modify the connection string in the application’s .config file to refer to the absolute physical path to the .edmx file.

B.

Modify the connection string in the application’s .config file to refer to the relative path to the .edmx file.

C.

Set the value of the .edmx file’s Metadata Artifact Processing property to Copy to Output Directory.

D.

Set the value of the .edmx files Build Action property to Copy to Output.

 

Correct Answer: C

 

 

QUESTION 60

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Communication Foundation (WCF) Data Services service. The service connects to a Microsoft SQL Server 2008 database. The service is hosted by an Internet Information Services (IIS) 6.0 Web server.

 

The application works correctly in the development environment. However, when you connect to the service on the production server, attempting to update or delete an entity results in an error.

 

You need to ensure that you can update and delete entities on the production server.

 

What should you do?

 

A.

Add the following line of code to the InitializeService method of the service. config.SetEntitySetAccessRule (“*”,EntitySetRights.WriteDelete | EntitySetRights.WriteInsert);

B.

Add the following line of code to the InitializeService method of the service. config.SetEntitySetAccessRule (“*”,EntitySetRights.WriteDelete | EntitySetRights.WriteMerge);

C.

Configure IIS to allow the PUT and DELETE verbs for the .svc Application Extension.

D.

Configure IIS to allow the POST and DELETE verbs for the .svc Application Extension.

 

Correct Answer: C

Explanation:

An OData client accesses data provided by an OData service using standard HTTP. The OData protocol largely follows the conventions defined by REST, which define how HTTP verbs are used. The most important of these verbs are:

GET: Reads data from one or more entities.

PUT: Updates an existing entity, replacing all of its properties.

MERGE: Updates an existing entity, but replaces only specified properties[2].

POST: Creates a new entity.

DELETE: Removes an entity.

Http Header Verbs Enumeration

http://msdn.microsoft.com/en-us/library/windows/desktop/aa364664(v=vs.85).aspx

WCF Data Services Overview

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

Introduction to OData Protocol

http://msdn.microsoft.com/en-us/data/hh237663

 

 

 

 

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…