Pass Your Exam On First Try Real Microsoft 70-516 Exam Braindumps (41-50)

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:
411
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?
 
A.    var query = leagues.Select(l => l.Teams.Select(t => t.Players));
B.    var query = leagues.Select(l => l.Teams.SelectMany(t => t.Players));
C.    var query = leagues.SelectMany(l => l.Teams.SelectMany(t => t.Players));
D.    var query = leagues.SelectMany(l => l.Teams.Select(t => t.Players));

Answer: C

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

A.    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.
B.    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.
C.    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.
D.    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.

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?

A.    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;
B.    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;
C.    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;
D.    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;

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?

A.    Integrated Security=SSPI;
B.    Persist Security Info=true;
C.    Persist Security Info=false;
D.    Integrated Security=false;

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?

A.    command.CommandText = "USE [pubs]; exec uspLoginAudit;";
using (SqlConnection connection = new SqlConnection( "Initial Catalog=AdventureWorks; Integrated Security=SSPI;
MultipleActiveResultSets=True")) {
   connection.Open();
   command.ExecuteNonQuery();
}
B.    command.CommandText = "exec uspLoginAudit;";
using (SqlConnection connection = new SqlConnection( "Integrated Security=SSPI;")) {
   connection.Open();
   command.ExecuteNonQuery();
}
C.    command.CommandText = "USE [pubs]; exec uspLoginAudit;";
using (SqlConnection connection = new SqlConnection( "Integrated Security=SSPI; Initial Catalog=AdventureWorks")) {
   connection.Open();
   command.ExecuteNonQuery();
}
D.    command.CommandText = "exec uspLoginAudit;";
using (SqlConnection connection = new SqlConnection( "Integrated Security=SSPI; Initial Catalog=pubs")) {
   connection.Open();
   command.ExecuteNonQuery();
}

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?

A.    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.
B.    1. Generate a MetadataWorkspace and create an ObjectContext for the model.
2. Create an ObjectSet fort he POCO classes.
3. Disable Proxy object creation on the ContextOptions of the ObjectContext.
C.    1. Generate an Entity Data Model fort he POCO classes.
2. Create an ObjectSet fort he POCO classes.
3. Disable Proxy object creation on the ContextOptions of the ObjectContext.
4. Enable lazy loading on the ContextOptions of the ObjectContext.
D.    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.

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 colomn.
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 comlex type with the name of the property in the Entity Framework Designer.
D.    Create a function import with the name of property in the Entity Framework Designer.

Answer: B

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

A.    Create a partial method named OnStateChanged in the partial class for the entity.
B.    Create a partial method named OnAttached in the partial class for the entity.
C.    Create an event handler to handle the ObjectStateManagerChanged event.
D.    Create an event handler to handle the ObjectMaterialized event.

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.
491
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?

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 complect type for each entity.

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?

A.    string SQL = “SELECT * FROM Customer Where “ + “CompanyName LIKE @companyName”;
var cmd = new SqlCommand(SQL,con);
cmd.Parameters.AddWithValue(“@companyName”, string.Format(“%{0}%”, companyName));
B.    string SQL = “SELECT * FROM Customer Where “ + “CompanyName LIKE @companyName”;
var cmd = new SqlCommand(SQL,con);
var param = new SqlParameter (“@companyName”, string.Format(“%{0}%”, companyName));
C.    string SQL = string.Format(“SELECT * FROM “ + “ Customer Where CompanyName LIKE {0}”,
                   new SqlCommand(“@companyName”, string.format(“%{0}%”, companyName)));
var cmd = new SqlCommand(SQL, con);
D.    string SQL = “SELECT” * FROM Customer @companyName;
var cmd = new sqlcommand(SQL,con);
cmd.Parameters.AddWithValue(“companyName”, string.format(“where companyName LIKE ‘%{0}%’”, companyName));

Answer: A

Pass Your Exam On First Try Real Microsoft 70-516 Exam Braindumps

Welcome To Visit PassLeader