PrepAway - Latest Free Exam Questions & Answers

Category: 70-516

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

Which code segment should you insert at line 12?

You have been assigned the task of writing code that executes an Entity SQL query that returns entity type objects that contain a property of a complex type.
(Line numbers are included for reference only.)

01 using (EntityCommand cmd = conn.CreateCommand())
02 {
03 cmd.CommandText = esqlQuery;
04 EntityParameter param = new EntityParameter();
05 param.ParameterName = “id”;
06 param.Value = 3;
07 cmd.Parameters.Add(param);
08 using (EntityDataReader rdr = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
09 {
10 while (rdr.Read())
11 {
12 …
13 Console.WriteLine(“Email and Phone Info:”);
14 for (int i = 0; i < nestedRecord.FieldCount; i++)
15 {
16 Console.WriteLine(” ” + nestedRecord.GetName(i) + “: ” + nestedRecord.GetValue(i));
17 }
18 }
19 }
20 }

Which code segment should you insert at line 12?

Whis code would fit this business rule?

You are a tasked with performing a code review. The business rule is the following:
* If INSERTs into the first table succeed, then INSERT into the second table.
* However, if the INSERTs into the second table fail, roll back the inserts in the second table but do not roll back the inserts in the first table.
* Although this can also be done by way of regular transactions, It needs to be performed using TransactionScope objects.

Whis code would fit this business rule?

Which code segment should you insert at line 11?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
You create a Database Access Layer (DAL) that is database-independent. The DAL includes the following code segment.
(Line numbers are included for reference only.)

01 static void ExecuteDbCommand(DbConnection connection)
02 {
03 if (connection != null){
04 using (connection){
05 try{
06 connection.Open();
07 DbCommand command = connection.CreateCommand();
08 command.CommandText = “INSERT INTO Categories (CategoryName) VALUES (‘Low Carb’)”;
09 command.ExecuteNonQuery();
10 }
11 …
12 catch (Exception ex){
13 Trace.WriteLine(“Exception.Message: ” + ex.Message);
14 }
15 }
16 }
17 }

You need to log information about any error that occurs during data access.
You also need to log the data provider that accesses the database. Which code segment should you insert at line 11?

What should your model contain?

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 Data Definition Language (DDL) script of the database contains the following code segment:

CREATE TABLE [Sales].[SalesOrderHeader](
[SalesOrderID] [int] IDENTITY(1,1) NOT NULL,
[BillToAddressID] [int] NOT NULL,

CONSTRAINT [PK_SalesOrderHeader_SalesOrderID]
PRIMARY KEY CLUSTERED ([SalesOrderID] ASC)
)

ALTER TABLE [Sales].[SalesOrderHeader]
WITH CHECK ADD CONSTRAINT [FK_SalesOrderHeader_Address]
FOREIGN KEY([BilIToAddressID])
REFERENCES [Person].[Address]([AddressID])

You create an ADO.NET Entity Framework model. You need to ensure that the entities of the model correctly map to the DDL of the database.
What should your model contain?

Which connection string should you add to the app.config file?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
You use the ADO.NET Entity Framework to model your entities.
The application connects to a Microsoft SQL Server 2008 database named AdventureWorks by using Windows Authentication.
Information about the required Entity Data Model (EDM) is stored in the following files:
* model.csdl
* model.ssdl
* model.msl

These files are embedded as resources in the MyCompanyData.dll file.You need to define the connection string
that is used by the application. Which connection string should you add to the app.config file?

Which code segment should you use?

You use Microsoft Visual Studio 2010 and Microsoft Entity Framework 4.0 to create an application.
The application connects to a Microsoft SQL Server database. You use the ADO.NET LINQ to SQL model to retrieve data from the database.
The applications contains the Category and Product entities as shown in the following exhibit:

You need to ensure that LINO to SQL executes only a single SQL statement against the database.
You also need to ensure that the query returns the list of categories and the list of products.
Which code segment should you use?

Exhibit:

What should you do?

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. The model includes the entity shown in the following exhibit:

You need to add a function that returns the number of years since a person was hired.
You also need to ensure that the function can be used within LINQ to Entities queries. What should you do?


Page 12 of 19« First...1011121314...Last »