New Updated Microsoft MCTS 70-516 Real Exam Questions and Answers Download 161-170

Ensurepass

QUESTION 161

The database contains orphaned Color records that are no longer connected to Part records. You need to clean up the orphaned records. You have an existing ContosoEntities context object named context. Which code segment should you use?

 

  1. var unusedColors = context.Colors.Where(c => !c.Parts.Any()).ToList();

foreach (var unused in unusedColors){

context.DeleteObject(unused)

}

context.SaveChanges();

 

  1. context.Colors.TakeWhile(c => !c.Parts.Any());

context.SaveChanges();

 

  1. context.Colors.ToList().RemoveAll(c => !c.Parts.Any());

context.SaveChanges();

 

  1. var unusedColors = context.Colors.Where(c => !c.Parts.Any());

context.DeleteObject(unusedColors);

context.SaveChanges();

 

Correct Answer: A

 

 

QUESTION 162

You need to write a LINQ query that can be used against a ContosoEntities context object named context to find all parts that have a duplicate name. Which of the following queries should you use? (Each correct answer presents a complete solution. Choose two).

 

  1. context.Parts.Any(p => context.Parts.Any(q => p.Name == q.Name));

  2. context.Parts.GroupBy(p => p.Name).Where(g => g.Count() > 1).SelectMany(x => x);

  3. context.Parts.SelectMany(p => context.Parts.Select(q => p.Name == q.Name && p.Id != q.Id));

  4. context.Parts.Where(p => context.Parts.Any(q => q.Name == p.Name && p.Id != q.Id);

 

Correct Answer: BD

 

 

QUESTION 163

You add a table to the database to track changes to part names. The table stores the following row values:

 

  • the username of the user who made the change

  • a part ID

  • the new part name

  • a DateTime value

 

You need to ensure detection of unauthorized changes to the row values. You also need to ensure that database users can view the original row values.

 

  1. Add a column named signature.

Use System.Security.Cryptography.RSA to create a signature for all of the row values. Store the signature in the signature column. Publish only the public key internally.

  1. Add a column named hash.

Use System.Security.Cryptography.MD5 to create an MD5 hash of the row values, and store in the hash column.

  1. Use System.Security.Cryptography.RSA to encrypt all the row values. Publish only the key internally.

  2. Use System.Security.Cryptography.DES to encrypt all the row values using an encryption key held by the application.

 

Correct Answer: A

 

 

QUESTION 164

The user interface requires that a paged view be displayed of all the products sorted in alphabetical order. The user interface supplies a current starting index and a page size in variables named startIndex and pageSize of type int. You need to construct a LINQ expression that will return the appropriate Parts from the database from an existing ContosoEntities context object named context. You begin by writing the following expression:

 

context.Parts

 

Which query parts should you use in sequence to complete the expression? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)

 

  1. .OrderBy(x => x.Name)

  2. .Skip(pageSize)

  3. .Skip(startIndex)

  4. .Take(pageSize);

  5. .Take(startIndex)

 

Correct Answer: ACD

 

 

QUESTION 165

You are developing a new feature in the application to display a list of all bundled products. You need to write a LINQ query that will return a list of all bundled products. Which query expression should you use?

 

  1. context.Parts.Cast<Product>()

.Where(p => p.Descendants.Any(d => d is Product))

 

  1. context.Parts.OfType<Product>()

.Where(p => p.Descendants.Any(d => d is Product))

 

  1. context.Parts.Cast<Product>()

.ToList()

.Where(p => p.Descendants.Any(d => d is Product))

 

  1. context.Parts.OfType<Product>()

.ToList()

.Where(p => p.Descendants.Any(d => d is Product))

 

Correct Answer: D

QUESTION 166

You use Microsoft .NET Framework 4.0 to develop an application that uses LINQ to SQL. The Product entity in the LINQ to SQL model contains a field named Productlmage. The Productlmage field holds a large amount of binary data. You need to ensure that the Productlmage field is retrieved from the database only when it is needed by the application. What should you do?

 

  1. Set the Update Check property on the Productlmage property of the Product entity to Never.

  2. Set the Auto-Sync property on the Productlmage property of the Product entity to Never.

  3. Set the Delay Loaded property on the Productlmage property of the Product entity to True.

  4. When the context is initialized, specify that the Productlmage property should not be retrieved by using DataLoadOptions

 

Correct Answer: C

 

 

QUESTION 167

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

 

SELECT VALUE product

FROM AdventureWorksEntities.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?

 

  1. SELECT TOP Stop VALUE product

FROM AdventureWorksEntities.Products AS product

ORDER BY product.ListPrice

SKIP @skip

 

  1. SELECT VALUE product

FROM AdventureWorksEntities.Products AS product

ORDER BY product.ListPrice

SKIP @skip LIMIT @limit

 

  1. SELECT SKIP @skip VALUE product

FROM AdventureWorksEntities.Products AS product

ORDER BY product.ListPrice

LIMIT @limit

 

  1. SELECT SKIP @skip TOP Stop VALUE product

FROM AdventureWorksEntities.Products AS product

ORDER BY product.ListPrice

 

Correct Answer: B

 

 

QUESTION 168

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application. You use the Entity Framework Designer to create the following Entity Data Model.

 

70-516-demo-22

 

The application contains a class as shown in the following code segment. (Line numbers are included for reference only.)

 

01 public class MyBaseClass : EntityObject

02 {

03 ….

04 }

 

You need to ensure that all generated entities inherit from MyBaseClass. What should you do?

 

  1. Change MyBaseClass to inherit from ObjectContext.

  2. Create a new ObjectQuery that uses MyBaseClass as the type parameter.

  3. Modify the generated code file so that all entities inherit from MyBaseClass.

  4. Use the ADO.NET EntityObject Generator template to configure all entities to inherit from MyBaseClass.

 

Correct Answer: D

 

 

 

 

 

 

 

 

QUESTION 169

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

 

70-516-demo-23

 

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

 

<Function Name=”Round” ReturnType=”Decimal”>

<Parameter Name=”val” Type=”Decimal” />

<DefiningExpression>

CAST(val as Edm.Int32)

</DefiningExpression>

</Function>

 

The application includes the following LINQ query.

 

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

 

  1. public static class DecimalHelper

{

[EdmFunction(“SqlServer”, “Round”)]

public static Decimal Round(this Decimal Amt)

{

throw new NotSupportedException();

}

}

 

  1. public static class DecimalHelper

{

[EdmFunction(“Edm”, “Round”)]

public static Decimal Round(this Decimal Amt)

{

throw new NotSupportedException();

}

}

 

  1. public static class DecimalHelper

{

public static SqlDecimal Round(this Decimal input)

{

return SqlDecimal.Round(input, 0);

}

}

 

  1. public static class DecimalHelper

{

public static Decimal Round(this Decimal input)

{

return (Decimal)(Int32)input;

}

}

 

Correct Answer: B

 

 

QUESTION 170

You use Microsoft .NET Framework 4.0 to develop an application. You write the following code to update data in a Microsoft SQL Server 2008 database. (Line numbers are included for reference only.)

 

01 private void ExecuteUpdate(SqlCommand cmd, string connString, string updateStmt)

02 {

03 …

04 }

 

You need to ensure that the update statement executes and that the application avoids connection leaks. Which code segment should you insert at line 03?

 

  1. SqlConnection conn = new SqlConnection(connString);

conn.Open();

cmd.Connection = conn;

cmd.CommandText = updateStmt;

cmd.ExecuteNonQuery();

cmd.Connection.Close();

 

  1. using (SqlConnection conn = new SqlConnection(connString))

{

cmd.Connection = conn;

cmd.CommandText = updateStmt;

cmd.ExecuteNonQuery();

cmd.Connection.Close();

}

 

  1. using (SqlConnection conn = new SqlConnection(connString))

{

conn.Open();

cmd.Connection = conn;

cmd.CommandText = updateStmt;

cmd.ExecuteNonQuery();

}

 

  1. SqlConnection conn = new SqlConnection(connString);

conn.Open();

cmd.Connection = conn;

cmd.CommandText = updateStmt;

cmd.ExecuteNonQuery();

 

Correct Answer: C

 

Instant Access to Download Latest Complete Collection of Microsoft MCTS 70-516 Real Exam

Try Microsoft MCTS 70-516 Free Demo