Microsoft TS: Accessing Data with Microsoft .NET Framework 4 Sample Questions:
1. 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 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 column's 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 update function without requiring changes in
the code.
What should you do?
A) Override the Update operation of the DataContext object.
B) Override the Delete 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.
2. You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 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 true. Use the GetData method of the TableAdapter to create a new DataTable.
B) Set the ClearBeforeFill property of the TableAdapter to false. Use the Fill method of the TableAdapter.
C) Set the ClearBeforeFill property of the TableAdapter to false. Use the GetData method of the TableAdapter to create a new DataTable.
D) Set the ClearBeforeFill property of the TableAdapter to true. Use the Fill method of the TableAdapter to load additional customers.
3. You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
The application uses the ADO.NET Entity Framework to model entities.
You need to create a database from your model. What should you do?
A) Run the edmgen.exe tool in FromSSDLGeneration mode.
B) Run the edmgen.exe tool in FullGeneration mode.
C) Use the Update Model Wizard in Visual Studio.
D) Use the Generate Database Wizard in Visual Studio. Run the resulting script against a Microsoft SQL Server database.
4. You have a ContosoEntities context object named context and a Color object stored in a variable named color.
You write the following code:
context.Colors.DeleteObject(color); context.SaveChanges();
When the code runs, it generates the following exception:
System.Data.UpdateException: An error occurred while updating the entries. See
the inner exception for detials. --->
System.Data.SqlClient.SqlException: The DELETE satement conflicted with the
REFERENCE constraint "FK_PartColor".
The conflict occurred in database "Contoso", table "dbo.Parts", column
'ColorId'
You need to resolve the exception without negatively impacting the rest of the application. What should you do?
A) Change the End2 OnDelete proprety of the FK_PartColor association from None to Cascade
B) Add a transation around the call to the SaveChanges() method and handle the exception by performing a retry.
C) Change the End1 OnDelete proprety of the FK_PartColor association from None to Cascade
D) Add code before the call to the DeleteObject() method to examine the collection of Part objects associated with the Color object and then assign null to the Color property for each Part object.
E) In the database, remove the foreign key association between the Parts table and the Colors table, and then update the entity data model.
5. 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.
The application includes self-tracking entities as shown in the following diagram.
There is a Person entity names person1 that has TrackChanges turned on.
You need to delete all e-mail addresses that are associated with person1 by using an ObjectContext.
What are two possible code segments that you can use to achieve this goal?
(Each correct answer presents a complete solution. Choose two).
A) person1.EMailAddresses = new TrackableCollection<EMailAddress>(); context.SaveChanges();
B) person1.EMailAddresses = null; context.SaveChanges();
C) while(person1.EMailAddresses.Count>0){
person1.EmailAddresses.RemoveAt(0);
}
context.SaveChanges();
D) foreach(var email in person1.EMailAddresses){
email.MarkAsDeleted();
}
context.SaveChanges();
Solutions:
| Question # 1 Answer: B | Question # 2 Answer: B | Question # 3 Answer: D | Question # 4 Answer: D | Question # 5 Answer: C,D |














1152 Customer Reviews
Quality and ValueITCertKing Practice Exams are written to the highest standards of technical accuracy, using only certified subject matter experts and published authors for development - no all study materials.
Tested and ApprovedWe are committed to the process of vendor and third party approvals. We believe professionals and executives alike deserve the confidence of quality coverage these authorizations provide.
Easy to PassIf you prepare for the exams using our ITCertKing testing engine, It is easy to succeed for all certifications in the first attempt. You don't have to deal with all dumps or any free torrent / rapidshare all stuff.
Try Before BuyITCertKing offers free demo of each product. You can check out the interface, question quality and usability of our practice exams before you decide to buy.
