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 database includes a table named dbo.Documents that contains a column with large binary dat a. You are creating the Data Access Layer (DAL). You add the following code segment to query the dbo.Documents table. (Line numbers are included for reference only.)
01public void LoadDocuments(DbConnection cnx)
02{
03var cmd = cnx.CreateCommand();
04cmd.CommandText = "SELECT * FROM dbo.Documents";
05...
06cnx.Open();
07
08ReadDocument(reader); }
You need to ensure that data can be read as a stream. Which code segment should you insert at line 07?
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?
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 database includes a table that contains information about all the employees. The database table has a field named EmployeeType that identifies whether an employee is a Contractor or a Permanent employee. You declare the Employee entity base type. You create a new Association entity named Contractor that inherits the Employee base type. You need to ensure that all Contractors are bound to the Contractor class. What should you do?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The application uses the ADO.NET Entity Framework to model entities. The application allows users to make changes to entities while disconnected from the central data store. You need to ensure that when the user connects to the central data store and retrieves new data, the application meets the following requirements:
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You are creating the data layer of the application. You write the following code segment. (Line numbers are included for reference only.)
01 public static SqlDataReader GetDataReader(string sql){
02 SqlDataReader dr;
03
04 return dr;
05 }
You need to ensure that the following requirements are met:
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.
01DataSet customerOrders = new DataSet();
02customerOrders.EnforceConstraints = true;
03ForeignKeyConstraint ordersFK = new ForeignKeyConstraint("ordersFK",
04customerOrders.Tables["Customers"].Columns["CustomerID"],
05customerOrders.Tables["Orders"].Columns["CustomerID"]);
06
07customerOrders.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?
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 write the following code segment that executes two commands against the database within a transaction. (Line numbers are included for reference only.)
01using (SqlConnection connection = new SqlConnection(cnnStr)) {
02connection.Open();
03SqlTransaction sqlTran = connection.BeginTransaction();
04SqlCommand command = connection.CreateCommand();
05command.Transaction = sqlTran;
06try {
07command.CommandText = "INSERT INTO Production.ScrapReason(Name) VALUES('Wrong size')";
08command.ExecuteNonQuery();
09command.CommandText = "INSERT INTO Production.ScrapReason(Name) VALUES('Wrong color')";
10command.ExecuteNonQuery();
11
12}
You need to log error information if the transaction fails to commit or roll back. Which code segment should you insert at line 11?
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?
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You use Microsoft ADO.NET Entity Data Model (EDM) to model entities. You create an entity named Person with a schema defined by the following XML fragment. You need to ensure that entities within the application are able to add properties related to the city, region, and country of Person's address. What should you do?
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 server. You need to ensure that applications
authenticate against user information stored in the database before the application is allowed to use the
service. Which two actions should you perform? (Each correct answer presents part of the solution. Choose
two.)