All Free Pass4sure PDF & VCE 70-516 Exam Questions (91-100)

QUESTION 91
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that uses the ADO.NET Entity Framework to model entities. You create an entity model as shown in the following diagram.
911
You need to ensure that all Person entities and their associated EmailAddresses are loaded. Which code segment should you use?

A.    var people = context.People.Include(“EmailAddresses”).ToList();
B.    var people = context.People.Except(new ObjectQuery<Person>(“Person.EmailAddresses”, context)).ToList();
C.    var people = context.People.Except(new ObjectQuery<Person>(“EmailAddresses”, context)).ToList();
D.    var people = context.People.Include(“Person.EmailAddresses”).ToList();

Answer: A

QUESTION 92
You use Microsoft .NET Framework 4.0 to develop an application that connects to a local Microsoft SQL Server 2008 database.
The application can access a high-resolution timer. You need to display the elapsed time, in sub-milliseconds (<1 millisecond),
that a database query takes to execute. Which code segment should you use?

A.    int Start = Environment.TickCount;
command.ExecuteNonQuery();
int Elapsed = (Environment.TickCount) – Start;
Console.WriteLine(“Time Elapsed: {0:N} ms”, Elapsed);
B.    Stopwatch sw = Stopwatch.StartNew();
command.ExecuteNonQuery() ;
sw.Stop() ;
Console.WriteLine(“Time Elapsed: {0:N} ms”, sw.Elapsed.TotalMilliseconds);
C.    DateTime Start = DateTime.UtcNow;
command.ExecuteNonQuery();
TimeSpan Elapsed = DateTime.UtcNow – Start;
Console.WriteLine(“Time Elapsed: {0:N} ms”, Elapsed.Milliseconds);
D.    Stopwatch sw = new Stopwatch();
sw.Start() ;
command.ExecuteNonQuery();
sw.Stop();
Console.WriteLine(“Time Elapsed: {0:N} ms”, sw.Elapsed.Milliseconds);

Answer: D

QUESTION 93
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application.
You use the ADO.NET Entity Framework Designer to model entities.
You need to associate a previously deserialized entity named person1 to an object context named model and persist changes to the database.
Which code segment should you use?

A.    person1.AcceptChanges();
model.SaveChanges();
B.    model.People.ApplyChanges(person1) ;
model.SaveChanges();
C.    model.AttachTo(“People”, person1);
model.SaveChanges();
D.    model.People.Attach(person1);
model.SaveChanges();

Answer: C

QUESTION 94
You use Microsoft .NET Framework 4.0 to develop an application that uses WCF Data Services to persist entities from the following Entity Data Model.
941
You create a new Blog instance named newBlog and a new Post instance named newPost as shown in the following code segment.
(Line numbers are included for reference only.)
01 Blog newBlog = new Blog();
02 Post newPost = new Post();
03 ….
04 Uri serviceUri = new Uri(“…”);
05 BlogsEntities context = new BlogsEntities(serviceUri);
06 ….
You need to ensure that newPost is related to newBlog through the Posts collection property and that newPost and newBlog are sent to the service.
Which code segment should you insert at line 06?

A.    context.AttachLink(newBlog, “Posts”, newPost);
context.SaveChanges(SaveChangesOptions.Batch) ;
B.    newBlog.Posts.Add(newPost);
context.AddToBlogs(newBlog);
context.AddToPosts(newPost);
context.SaveChanges(SaveChangesOptions.Batch);
C.    newBlog.Posts.Add(newPost);
context.AttachTo(“Blogs”, newBlog);
context.AttachTo(“Posts”, newPost);
context.SaveChanges(SaveChangesOptions.Batch);
D.    newBlog.Posts.Add(newPost);
context.UpdateObject(newBlog);
context.UpdateObject(newPost);
context.SaveChanges(SaveChangesOptions.Batch);

Answer: C

QUESTION 95
You use Microsoft .NET Framework 4.0 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.
951
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) ;

Answer: A

QUESTION 96
You use Microsoft .NET Framework 4.0 to develop an application that exposes a WCF Data Services endpoint.
The endpoint uses an authentication scheme that requires an HTTP request that has the following header format.
GET  /OData.svc/Products(1)
Authorization: WRAP access_token “123456789”
You add the following method to your DataService implementation.
01 protected override void OnStartProcessingRequest(ProcessRequestArgs args)
02 {
03      ….
04 }
You need to ensure that the method retrieves the authentication token. Which line of code should you use?

A.    string token = args.OperationContext.RequestHeaders[“Authorization”];
B.    string token = args.OperationContext.RequestHeaders[“WRAP access_token”];
C.    string token = args.OperationContext.ResponseHeaders[“Authorization”];
D.    string token = args.OperationContext.ResponseHeaders[“WRAP access_token”];

Answer: A

QUESTION 97
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server 2008 database.
You use the ADO.NET Entity Framework Designer to model entities. You add the following stored procedure to the database, and you add a function import to the model.
CREATE PROCEDURE [dbo].[InsertDepartment]
   @Name nvarchar(50),
   @ID int NULL OUTPUT
AS
   INSERT INTO Department (Name) VALUES (@Name)
   SELECT @ID = SCOPE_IDENTITY()
You need to insert a new department and display the generated ID. Which code segment should you use?

A.    using (SchoolEntities context = new SchoolEntities())
{
   var  id = new ObjectParameter(“ID”, typeof(int));
   context.InsertDepartment(“Department 1”, id);
   Console.WriteLine(id.Value);
}
B.    using (SchoolEntities context = new SchoolEntities())
{
   var id = context.InsertDepartment(“Department 1”, null);
   Console.WriteLine(id);
}
C.    using (SchoolEntities context = new SchoolEntities())
{
   ObjectParameter id = null;
   context.InsertDepartment(“Department 1”, id);
   Console.WriteLine(id.Value);
}
D.    using (SchoolEntities context = new SchoolEntities())
{
   var id = new ObjectParameter(“ID”, null));
   context.InsertDepartment(“Department 1”, id);
   Console.WriteLine(id.Value);
}

Answer: A

QUESTION 98
You use Microsoft .NET Framework 4.0 to develop an ASP.NET Web application that connects to a Microsoft SQL Server 2008 database.
The application uses Integrated Windows authentication in Internet Information Services (IIS) to authenticate users.
A connection string named connString defines a connection to the database by using integrated security.
You need to ensure that a SqlCommand executes under the application pool’s identity on the database server.
Which code segment should you use?

A.    using (var conn = new SqlConnection())
{
   conn.ConnectionString = connString;
   SqlCommand cmd = null;
   using (HostingEnvironment.Impersonate())
   {
      cmd = new SqlCommand(“SELECT * FROM BLOG”, conn);
   }
   conn.Open();
   var result = cmd.ExecuteScalar();
}
B.    using (var conn = new SqlConnection(connString))
{
   var cmd = new SqlCommand (“SELECT * FROM BLOG, conn);
   conn.Open();
   using(HostingEnvironment.Impersonate())
   {
      var result = cmd.ExecuteScalar();
   }
}
C.    using (var conn = new SqlConneccion())
{
   using (HostingEnvironroent.Impersonate())
   {
      conn.ConnectionString = connString;
   }
   var cmd = new SqlCommand(“SELECT * FROM BLOG, conn);
   conn.Open() ;
   var result = cmd.ExecuteScalar();
}
D.    using (var conn = new SqlConnection())
{
   conn.ConnectionString = connString;
   var cmd = new SqlCommand(“SELECT * FROM BLOG”, conn);
   using (HostingEnvironment.Impersonate())
   {
      conn.Open();
   }
   var result = cmd.ExecuteScalar();
}

Answer: D

QUESTION 99
You use Microsoft .NET Framework 4.0 to develop an ASP.NET 4 Web application.
You need to encrypt the connection string information that is stored in the web.config file. The application is deployed to multiple servers.
The encryption keys that are used to encrypt the connection string information must be exportable and importable on all the servers.
You need to encrypt the connection string section of the web.config file so that the file can be used on all of the servers.
Which code segment should you use?

A.    Configuration config = WebConfigurationManager.OpenWebConfiguration(“~”) ;
ConnectionStringsSection section = (ConnectionStringsSection)config.GetSection(“connectionStrings”);
section.Sectionlnformation.ProtectSection(“RsaProtectedConfigurationProvider”);
config.Save();
B.    Configuration config = WebConfigurationManager.OpenMachineConfiguration(“~”);
ConnectionStringsSection section = (ConnectionStringsSection)config.GetSection(“connectionStrings”);
section.Sectionlnformation.ProtectSection(“RsaProtectedConfigurationProvider’*);
config.Save();
C.    Configuration config = WebConfigurationHanager.OpenWebConfiguration (“~”) ;
ConnectionStringsSection section = (ConnectionStringsSection)config.GetSection(“connectionStrings”) ;
section.Sectionlnformation.ProtectSection(“DpapiProtectedConfigurationProvider”);
config.Save ();
D.    Configuration config = WebConfigurationManager.OpenMachineConfiguration (“~”) ;
ConnectionStringsSection section = (ConnectionStringsSection)config.GetSection(“connectionStrings”) ;
section.Sectionlnformation.ProtectSection(“DpapiProtectedConfigurationProvider”);
config.Save () ;

Answer: A

QUESTION 100
You use Microsoft .NET Framework 4.0 and the Entity Framework to develop an application.
You create an Entity Data Model that has an entity named Customer. You set the optimistic concurrency option for Customer.
You load and modify an instance of Customer named loadedCustomer, which is attached to an ObjectContext named context.
You need to ensure that if a concurrency conflict occurs during a save, the application will load up-to-date values from
the database while preserving local changes. Which code segment should you use?

A.    try
{
   context.SaveChanges();
}
catch(EntitySqlException ex)
{
   context.Refresh(RefreshMode.StoreWins, loadedCustomer);
}
B.    try
{
   context.SaveChanges();
}
catch(OptimisticConcurrencyException ex)
{
   context.Refresh(RefreshMode.ClientWins, loadedCustomer);
}
C.    try
{
   context.SaveChanges();
}
catch(EntitySqlException ex)
{
   context.Refresh(RefreshMode.ClientWins, loadedCustomer);
}
D.    try
{
   context.SaveChanges();
}
catch(OptimisticConcurrencyException ex)
{
   context.Refresh(RefreshMode.StoreWins, loadedCustomer);
}

Answer: B

All Free Pass4sure PDF & VCE 70-516 Exam Questions