Attention Please:Professional new version Microsoft 70-516 PDF and VCE dumps can now free download on Flydumps.com,all are updated timely by our experts covering all Microsoft 70-516 new questions and questions.100 percent pass your exam.
QUESTION: 1
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an
application. The application contains the following code segment. (Line numbers are included
for reference only.)
01 class DataAccessLayer
02 {
03 private static string connString;
04
05 …
06 public static DataTable GetDataTable(string command){
07
08 …
09 }
10 }
You need to define the connection life cycle of the DataAccessLayer class. You also need to
ensure that the application uses the minimum number of connections to the database. What
should you do?
A. Insert the following code segment at line 04.
private static SqlConnection conn = new SqlConnection(connString);
public static void Open(){
conn.Open();
}
public static void Close(){
conn.Close();
}
B. Insert the following code segment at line 04.
private SqlConnection conn = new SqlConnection(connString);
public void Open(){ conn.Open(); } public void Close(){ conn.Close();
}
C. Replace line 01 with the following code segment. class DataAccessLayer :
IDisposable Insert the following code segment to line 04.
private SqlConnection conn = new SqlConnection(connString);
public void Open(){
conn.Open();
}
public void Dispose(){
conn.Close();
}
D. Insert the following code segment at line 07.
using (SqlConnection conn = new SqlConnection(connString)){
conn.Open();
}
Answer: D
QUESTION: 2 You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Windows Communication Foundation (WCF) Data Services service. You discover that when an application submits a PUT or DELETE request to the Data Services service, it receives an error. You need to ensure that the application can access the service. Which header and request type should you use in the application?
A. an X-HTTP-Method header as part of a POST request
B. an X-HTTP-Method header as part of a GET request
C. an HTTP ContentType header as part of a POST request
D. an HTTP ContentType header as part of a GET request
Answer: A
QUESTION: 3 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.
Answer: C
QUESTION: 4 You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server 2008 database by using SQL Server authentication. The application contains the following connection string. SERVER=DBSERVER-01; DATABASE=pubs; uid=sa; pwd=secret; You need to ensure that the password value in the connection string property of a SqlConnection object does not exist after the Open method is called. What should you add to the connection string?
A. Persist Security Info=True
B. Trusted_Connection=True
C. Persist Security Info=False
D. Trusted_Connection=False
Answer: C
QUESTION: 5 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 manage order data. The application makes a Web service call to obtain orders from an order-tracking system. You need to ensure that the orders are added to the local data store. Which method should you call on the ObjectContext?
A. Attach
B. AttachTo
C. AddObject
D. ApplyCurrentValues
Answer: A
QUESTION: 6 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.)
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));
}
}
}
Answer: B
QUESTION: 7 You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create a Microsoft ASP.NET application. You want to connect the application to a Microsoft SQL Server Express 2008 database named MyDatabase. The primary database file is named MyDatabase.mdf and it is stored in the App_Data folder. You need to define the connection string. Which connection string should you add to the Web.config file?
A. Data Source=localhost; Initial Catalog=MyDataBase; Integrated Security=SSPI; User Instance=True
B. Data Source=.\SQLEXPRESS; Initial Catalog=MyDataBase; Integrated Security=True; User Instance=True
C. Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\MyDatabase.mdf; Integrated Security=True; User Instance=True
D. Data Source =SQLEXPRESS; AttachDbFilename=|DataDirectory|\App_Data\MyDatabase.mdf; Integrated Security=SSPI; User Instance=True
Answer: C
QUESTION: 8
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an
application. You use the ADO.NET Entity Framework to model entities. You write the
following code segment. (Line numbers are included for reference only.)
01 AdventureWorks Entities context = n ew AdventureWorksEntities (
02 ” http://localhost:1234/AdventureWorks.svc ”
03 );
04
05 var q = from c in context.Customers
06 where c.City == “London”
07 orderby c.CompanyName
08 select c;
You need to ensure that the application meets the following requirements:
-Compares the current values of unmodified properties with values returned from the data source
–
Marks the property as modified when the properties are not the same Which code segment should you insert at line 04?
A.
context.MergeOption = MergeOption.AppendOnly;
B.
context.MergeOption = MergeOption.PreserveChanges;
C.
context.MergeOption = MergeOption.OverwriteChanges;
D.
context.MergeOption = MergeOption.NoTracking;
Answer: B
QUESTION: 9
You use Microsoft .NET Framework 4 to develop an application. The configuration file
contains the following code segment.
<configuration>
<connectionStrings>
<add name=”AdventureWorksLT”
connectionString=”Data Source=SQL01;
Initial Catalog=AdventureWorksLT;
Integrated Security=True;”
providerName=”System.Data.SqlClient”/>
</connectionStrings>
</configuration>
You need to retrieve the connection string named AdventureWorksLT from the configuration
file. Which line of code should you use?
A. var connectionString = ConfigurationManager .ConnectionStrings[“AdventureWorksLT”].ConnectionString;
B. var connectionString = ConfigurationManager .ConnectionStrings[“AdventureWorksLT”].Name;
C. var connectionString = ConfigurationManager .AppSettings[“AdventureWorksLT”];
D. var connectionString = ConfigurationSettings .AppSettings[“AdventureWorksLT”];
Answer: A
QUESTION: 10 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 SqlCommand 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 (); }
Answer: A
QUESTION: 11 You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server database and contains a LINQ to SQL data model. The data model contains a function named createCustomer that calls a stored procedure. The stored procedure is also named createCustomer. The createCustomer function has the following signature. createCustomer (Guid customerID, String customerName, String address1) The application contains the following code segment. (Line numbers are included for reference only.) 01 CustomDataContext context = new CustomDataContext(); 02 Guid userID = Guid.NewGuid(); 03 String address1 = “1 Main Steet”; 04 String name = “Marc”;
You need to use the createCustomer stored procedure to add a customer to the database. Which code segment should you insert at line 05?
A. context.createCustomer(userID, name , address1)
B. context.ExecuteCommand(“createCustomer”, userID, name , address1);
C. Customer customer = new Customer() { ID = userID,
Address1 = address1, Name = name ,
};
context.ExecuteCommand(“createCustomer”, customer);
D. Customer customer = new Customer() { ID = userID,
Address1 = address1, Name = name ,
};
context.ExecuteQuery(typeof(Customer), “createCustomer”, customer);
Answer: A
QUESTION: 12 You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You use a TableAdapter object to load a DataTable object. The DataTable object is used as the data source for a GridView control to display a table of customer information on a Web page. You need to ensure that the application meets the following requirements:
–
Load only new customer records each time the page refreshes.
–
Preserve existing customer records. What should you do?
A.
Set the ClearBeforeFill property of the TableAdapter to false. Use the Fill method of the TableAdapter to load additional customers.
B.
Set the ClearBeforeFill property of the TableAdapter to false. Use the GetData method of the TableAdapter to create a new DataTable.
C.
Set the ClearBeforeFill property of the TableAdapter to true. Use the Fill method of the TableAdapter to load additional customers.
D.
Set the ClearBeforeFill property of the TableAdapter to true. Use the GetData method of the TableAdapter to create a new DataTable.
Answer: A
QUESTION: 13 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 performs a database query within a transaction. You need to ensure that the application can read data that has not yet been committed by other transactions. Which IsolationLevel should you use?
A. ReadUncommitted
B. ReadCommitted
C. RepeatableRead
D. Unspecified
Answer: A
QUESTION: 14
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an
application. You create a stored procedure to insert a new record in the Categories table
according to following code segment.
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. (Line numbers are included for reference only).
01 private static void ReturnIdentity(string connectionString)
02 {
03 using (SqlConnection connection = new SqlConnection(connectionString))
04 {
05 SqlDataAdapter adapter = new SqlDataAdapter(
06 “SELECT CategoryID, CategoryName FROM dbo.Categories”,connection);
07 adapter.InsertCommand = new SqlCommand(“InsertCategory”, connection);
08 adapter.InsertCommand.CommandType = CommandType.StoredProcedure;
09 SqlParameter rowcountParameter = adapter.InsertCommand.Parameters.Add(
10 “@RowCount”, SqlDbType.Int);
11
12 adapter.InsertCommand.Parameters.Add(
13 “@CategoryName”, SqlDbType.NChar, 15, “CategoryName”);
14 SqlParameter identityParameter = adapter.InsertCommand.Parameters.Add(
15 “@Identity”, SqlDbType.Int, 0, “CategoryID”);
16
17 DataTable categories = new DataTable();
18 adapter.Fill(categories);
19 DataRow categoryRow = categories.NewRow();
20 categoryRow[“CategoryName”] = “New Beverages”;
21 categories.Rows.Add(categoryRow);
22 adapter.Update(categories);
23 Int32 rowCount = (Int32)adapter.InsertCommand.Parameters[“@RowCount”].Value;
24 }
25 }
You need to retrieve the identity of the new record. You also need to retrieve the row count.
What should you do?
A. Insert the following code segment at line 11. rowcountParameter.Direction =
ParameterDirection.ReturnValue; Insert the following c ode segment at line 16.
identityParameter.Direction = ParameterDirection.ReturnValue;
B. Insert the following code segment at line 11. rowcountParameter.Direction =
ParameterDirection.Output;
Insert the following code segment at line 16. identityParameter.Direction =
ParameterDirection.Output;
C. Insert the following code segment at line 11.
rowcountParameter.Direction = ParameterDirection.ReturnValue; Insert the following code
segment at line 16. identityParameter.Direction = ParameterDirection.Output;
D. Insert the following code segment at line 11. rowcountParameter.Direction =
ParameterDirection.Output; Insert the following code segment at line 16.
identityParameter.Direction = ParameterDirection.ReturnValue;
Answer: C
QUESTION: 15 You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to develop an application. You use the ADO.NET Entity Framework Designer to model entities. The
There is a Person entity named person1 that has Track Changes turned on. You need to delete all e-mail addresses that are associated with person1 by using an ObjectContext named context. What are two possible code segments that you can use to achieve this goal? (Each correct answer presents a complete solution. Choose two).
A. foreach(var email in person1.EmailAddresses)
{
email.MarkAsDeleted();
}
context.SaveChanges();
B. while(person1.EmailAddresses.Count() > 0)
{
person1.EmailAddresses.RemoveAt(0);
}
context.SaveChanges();
C. person1.EmailAddresses = null;
context.SaveChanges();
D. person1.EmailAddresses = new TrackableCollection<EmailAddress>();
context.SaveChanges();
Answer: A, B
QUESTION: 16 You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application uses the ADO.NET Entity Framework to manage customer and related order records. You add a new order for an existing customer. You need to associate the Order entity with the Customer entity. What should you do?
A. Set the Value property of the EntityReference of the Order entity.
B. Call the Add method on the EntityCollection of the Order entity.
C. Use the AddObject method of the ObjectContext to add both Order and Customer entities.
D. Use the Attach method of the ObjectContext to add both Order and Customer entities.
Answer: A
QUESTION: 17 You use Microsoft .NET Framework 4 to develop an application that uses the Entity Framework. The application has an entity model with a Person entity. A Person instance named person1 and an ObjectContext instance named model exist. You need to delete the person1 instance. Which code segment should you use?
A. model.DeleteObject(person1);
model.SaveChanges();
B. model.Detach(person1); model.SaveChanges();
C. model.ExecuteStoreCommand(“Delete”, new [] { new ObjectParameter(“Person”, person1) }); model.SaveChanges();
D. model.ExecuteFunction(“Detach”, new [] { new ObjectParameter(“Person”, person1) }); model.SaveChanges();
Answer: A
QUESTION: 18 You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application connects to a Microsoft SQL Server database. You use the ADO.NET Entity Framework to manage persistence-ignorant entities. You create an ObjectContext instance named context. Then, you directly modify properties on several entities. You need to save the modified entity values to the database.Which code segment should you use?
A. context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);
B. context.SaveChanges(SaveOptions.DetectChangesBeforeSave);
C. context.SaveChanges(SaveOptions.None);
D. context.SaveChanges();
Answer: B
QUESTION: 19
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 has
two DataTable objects that reference the Customers and Orders tables in the database. The
application contains the following code segment. (Line numbers are included for reference
only.)
01 DataSet customerOrders = new DataSet();
02 customerOrders.EnforceConstraints = true;
03 ForeignKeyConstraint ordersFK = new ForeignKeyConstraint(“ordersFK”,
04 customerOrders.Tables[“Customers”].Columns[“CustomerID”],
05 customerOrders.Tables[“Orders”].Columns[“CustomerID”]);
07 customerOrders.Tables[“Orders”].Constraints.Add(ordersFK);
You need to ensure that an exception is thrown when you attempt to delete Customer records
that have related Order records. Which code segment should you insert at line 06?
A. ordersFK.DeleteRule = Rule.SetDefault;
B. ordersFK.DeleteRule = Rule.None;
C. ordersFK.DeleteRule = Rule.SetNull;
D. ordersFK.DeleteRule = Rule.Cascade;
Answer: B
QUESTION: 20 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. The application uses DataContexts to query the database. You create a function that meets the following requirements: Updates the Customer table on the database when a customer is marked as deleted. Updates the related entries in other tables (CustomerAddress, CustomerContacts) by marking them as deleted. Prevents consumer code from setting the Deleted columns value directly. You need to ensure that the function verifies that customers have no outstanding orders before they are marked as deleted. You also need to ensure that existing applications can use the updated function without requiring changes in the code. What should you do?
A. Override the Delete operation of the DataContext object.
B. Override the Update operation of the DataContext object.
C. Modify the SELECT SQL statement provided to the DataContext object to use an INNER JOIN between the Customer and Orders tables.
D. Add new entities to the DataContext object for the Customers and Orders tables.
Answer: A
Our material on our site Microsoft 70-516 is exam-oriented, keeping in view the candidates requirements and level of understanding.Microsoft 70-516 materials are in the most popular and easy-to-use PDF version. You can use it on any devices with you anywhere.