New Updated Microsoft MCTS 70-516 Real Exam Questions and Answers Download 41-50

Ensurepass

QUESTION 41

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server database. You create the classes shown in the following exhibit:

 

70-516-demo-5

 

You add the following code segment to the application. (Line numbers are included for reference only.)

 

01 public void QueryPlayers (List <League> leagues) {

02 …

03 }

You create a LINQ query to retrieve a collection of Player objects. You need to ensure that the collection includes all the players from each team and every league. Which code segment should you insert at line 02?

 

  1. var query = leagues.Select(l => l.Teams.Select(t => t.Players));

  2. var query = leagues.Select(l => l.Teams.SelectMany(t => t.Players));

  3. var query = leagues.SelectMany(l => l.Teams.SelectMany(t => t.Players));

  4. var query = leagues.SelectMany(l => l.Teams.Select(t => t.Players));

 

Correct Answer: C

 

 

QUESTION 42

How do you call a model-defined function as static method on a custom class?

 

  1. Add a class to your application with a static method that does the following:

Apply an EdmFunctionAttribute to the method and ensure it accepts an IQueryable argument and returns the results of the Execute method that is returned by the Provider property.

 

  1. Add a class to your application with a static method that does the following:

Apply an EdmFunctionAttribute to the method and ensure it accepts IEntityWithRelationships argument and returns the results of the Execute method that is returned by the Provider property.

  1. Add a class to your application with a static method that does the following:

Apply an EdmFunctionAttribute to the method and ensure it accepts ICollection argument and returns the results of the Execute method that is returned by the Provider property.

 

  1. Add a class to your application with a static method that does the following:

Apply an EdmFunctionAttribute to the method and ensure it accepts and returns the results of the Execute method that is returned by the Provider property.

 

Correct Answer: A

 

 

QUESTION 43

The database contains a table named Categories. The Categories table has a primary key identity column named CategoryID. The application inserts new records by using the following stored procedure.

 

CREATE PROCEDURE dbo.InsertCategory

@CategoryName nvarchar(15),

@Identity int OUT

AS

INSERT INTO Categories (CategoryName) VALUES(@CategoryName)

SET @Identity = SCOPE_IDENTITY()

RETURN @@ROWCOUNT

 

You write the following code segment.

 

SqlDataAdapter adapter = new SqlDataAdapter(“SELECT categoryID, CategoryName

FROM dbo.Categories”,connection);

adapter.InsertCommand = new SqlCommand(“dbo.InsertCategory”, connection);

adapter.InsertCommand.CommandType = commandType.StoredProcedure; adapter.

InsertCommand.Parameters.Add(new SqlParameter(“@CategoryName”, SqlDbType.

NVarChar, 15,”CategoryName”));

 

You need to retrieve the identity value for the newly created record. Which code segment should you add?

 

  1. SqlParameter parameter = adapter.InsertCommand.Parameters.Add(“@CategoryName”, SqlDbType.Int); parameter.Direction = ParameterDirection.Output;

parameter = adapter.InsertCommand.Parameters.Add(“@Identity”, SqlDbType.Int, 0, “CategoryID”);

parameter.Direction = ParameterDirection.Output;

 

  1. SqlParameter parameter = adapter.InsertCommand.Parameters.Add(“@CategoryName”, SqlDbType.Int); parameter.Direction = ParameterDirection.Output;

parameter = adapter.InsertCommand.Parameters.Add(“@Identity”, SqlDbType.Int, 0, “CategoryID”);

parameter.Direction = ParameterDirection.ReturnValue;

 

  1. SqlParameter parameter = adapter.InsertCommand.Parameters.Add(“@RowCount”, SqlDbType.Int);

parameter.Direction = ParameterDirection.ReturnValue;

parameter = adapter.InsertCommand.Parameters.Add(“@Identity”, SqlDbType.Int, 0, “CategoryID”);

parameter.Direction = ParameterDirection.Output;

 

  1. SqlParameter parameter = adapter.InsertCommand.Parameters.Add(“@RowCount”, SqlDbType.Int);

parameter.Direction = ParameterDirection.Output;

parameter = adapter.InsertCommand.Parameters.Add(“@Identity”, SqlDbType.Int, 0, “CategoryID”);

parameter.Direction = ParameterDirection.ReturnValue;

 

Correct Answer: C

 

 

QUESTION 44

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 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.

 

“Data Source=myServerAddress; Initial Catalog=myDataBase; User Id=myUsername; Password=secret;”

 

You need to ensure that the database credentials are secure. Which is the correct Property to insert?

 

  1. Integrated Security=SSPI;

  2. Persist Security Info=true;

  3. Persist Security Info=false;

  4. Integrated Security=false;

 

Correct Answer: C

 

 

QUESTION 45

You use Microsoft .NET Framework 4.0 to develop an ASP.NET application. The application uses Integrated Windows authentication. The application accesses data in a Microsoft SQL Server 2008 database that is located on the same server as the application. You use the following connection string to connect to the database.

 

Integrated Security=SSPI; Initial Catalog=AdventureWorks;

 

The application must also execute a stored procedure on the same server on a database named pubs. Users connect to the ASP.NET application through the intranet by using Windows-based authentication. You need to ensure that the application will use connection pooling whenever possible and will keep the number of pools to a minimum. Which code segment should you use?

  1. command.CommandText = “USE [pubs]; exec uspLoginAudit;”;

using (SqlConnection connection = new SqlConnection( “Initial Catalog=AdventureWorks; Integrated

Security=SSPI; MultipleActiveResultSets=True”)) {

connection.Open();

command.ExecuteNonQuery();

}

 

  1. command.CommandText = “exec uspLoginAudit;”;

using (SqlConnection connection = new SqlConnection( “Integrated Security=SSPI;”)) { connection. Open();

command.ExecuteNonQuery();

}

command.CommandText = “USE [pubs]; exec uspLoginAudit;”;

 

  1. using (SqlConnection connection = new SqlConnection( “Integrated Security=SSPI; Initial

Catalog=AdventureWorks”)) { connection.Open();

command.ExecuteNonQuery();

}

 

  1. command.CommandText = “exec uspLoginAudit;”;

using (SqlConnection connection = new SqlConnection( “Integrated Security=SSPI; Initial Catalog=pubs”)) { connection.Open();

command.ExecuteNonQuery();

}

 

Correct Answer: C

 

 

QUESTION 46

You use Microsoft Visual Studio 2010 and .NET Framework 4.0 to enhance and existing application use Entity Framework. The classes that represent the entites 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?

 

  1. 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.

 

  1. 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.

 

  1. 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.

 

  1. 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

 

 

QUESTION 47

You use Microsoft Visual Studio 2010 and .NET Framework 4.0 to develop an application. You use 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 database column. You need to add the property to product. What should you do?

 

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

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

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

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

 

Correct Answer: B

 

 

QUESTION 48

You use Microsoft Visual Studio 2010 and .NET Framework 4.0 to develop an application that uses the Entity Framework. You need to execute custom logic when an entity is attached to the ObjectContext. What should you do?

 

  1. Create a partial method named OnStateChanged in the partial class for the entity.

  2. Create a partial method named OnAttached in the partial class for the entity.

  3. Create an event handler to handle the ObjectStateManagerChanged event.

  4. Create an event handler to handle the ObjectMaterialized event.

 

Correct Answer: C

 

 

QUESTION 49

You use Microsoft Visual Studio 2010 and .NET Framework 4.0 to develop an application that uses the Entity Data Model for the fallowing database tables.

 

70-516-demo-6

 

You need to ensure that the entity that is mapped to the ContectTypeDerived table derives from the entity that is mapped to the ContentTypeBase table. What should you do?

 

  1. Use a Table-Per-Type mapping method.

  2. Use a Table-Per-Hierarchy mapping method.

  3. Create a function import for each entity.

  4. Create a complex type for each entity.

 

Correct Answer: A

 

 

QUESTION 50

You use Microsoft Visual Studio 2010 and .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server 2008 database. The application contains the following code segment.

 

string SQL = string.Format(“SELECT * FROM Customer WHERE CompanyName LIKE ,,%{0}%, companyName);

var cmd = new SqlCommand(SQL, con);

 

You need to reduce the vulnerability to SQL injection attacks. Which code segment should you use?

 

  1. string SQL = “SELECT * FROM Customer Where ” + “CompanyName LIKE @companyName”;

var cmd = new SqlCommand(SQL,con);

cmd.Parameters.AddWithValue(“@companyName”, string.Format(“%,0-%”, companyName));

 

  1. string SQL = “SELECT * FROM Customer Where ” + “CompanyName LIKE @companyName”; var cmd = new SqlCommand(SQL,con);

var param = new SqlParameter (“@companyName”, string.Format(“%,0-%”, companyName));

 

  1. string SQL = string.Format(“SELECT * FROM ” + ” Customer Where CompanyName LIKE ,0-“, new SqlCommand(“@companyName”, string.format(“%,0-%”, companyName)));

var cmd = new SqlCommand(SQL, con);

 

  1. string SQL = “SELECT” * FROM Customer @companyName;

var cmd = new sqlcommand(SQL,con);

cmd.Parameters.AddWithValue(“companyName”, string.format(“where companyName LIKE `%,0-%'”, companyName));

 

Correct Answer: A

 

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

Try Microsoft MCTS 70-516 Free Demo

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.