PrepAway - Latest Free Exam Questions & Answers

Category: 70-516

Exam 70-516: TS: Accessing Data with Microsoft .NET Framework 4

Which two actions should you perform?

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 manage Plain Old CLR Objects (POCO) entities.
You create a new POCO class. You need to ensure that the class meets the following requirements:
* It can be used by an ObjectContext.
* It is enabled for change-tracking proxies.

Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)

Which ObjectContext method should you call after changes are made to the entities?

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.
You use the ADO.NET Entity Framework to model your entities. You use ADO.NET self-tracking entities.
You need to ensure that the change-tracking information for the self-tracking entities can be used to update the database.
Which ObjectContext method should you call after changes are made to the entities?

Which code segment should you use?

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

Which code segment should you insert at line 05?

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 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”;
05 …

You need to use the createCustomer stored procedure to add a customer to the database.
Which code segment should you insert at line 05?

Which code segment should you insert at line 02?

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.
The application uses a DataTable named OrderDetailTable that has the following columns:
* ID
* OrderID
* ProductID
* Quantity
* LineTotal

Some records contain a null value in the LineTotal field and 0 in the Quantity field.
You write the following code segment. (Line numbers are included for reference only.)

01 DataColumn column = new DataColumn(“UnitPrice”, typeof(double));
02 …
03 OrderDetailTable.Columns.Add(column);

You need to add a calculated DataColumn named UnitPrice to the OrderDetailTable object.
You also need to ensure that UnitPrice is set to 0 when it cannot be calculated.
Which code segment should you insert at line 02?

Which code segment should you insert at line 06?

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.
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”]);
06 …
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?

What should you do?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create a Windows Communication
Foundation (WCF) Data Services service. You deploy the data service to the following URL: http://contoso.com/Northwind.svc.
You add the following code segment. (Line numbers are included for reference only.)

01 var uri = new Uri(@”http://contoso.com/Northwind.svc/”);
02 var ctx = new NorthwindEntities(uri);
03 var categories = from c in ctx.Categories select c;
04 foreach (var category in categories) {
05 PrintCategory(category);
06 …
07 foreach (var product in category.Products) {
08 …
09 PrintProduct(product);
10 }
11 }

You need to ensure that the Product data for each Category object is lazy-loaded. What should you do?

Which code segment should you insert at line 06?

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 a DataSet object in the application.
You add two DataTable objects named App_Products and App_Categories to the DataSet.
You add the following code segment to populate the DataSet object.
(Line numbers are included for reference only.)

01 public void Fill(SqlConnection cnx, DataSet ds)
02 {
03 var cmd = cnx.CreateCommand();
04 cmd.CommandText = “SELECT * FROM dbo.Products; ” + “SELECT * FROM dbo.Categories”;
05 var adapter = new SqlDataAdapter(cmd);
06 …
07 }

You need to ensure that App_Products and App_Categories are populated from the dbo.Products and dbo.Categories database tables.
Which code segment should you insert at line 06?


Page 18 of 19« First...10...1516171819