70-516 無料問題集「Microsoft TS: Accessing Data with Microsoft .NET Framework 4」
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 create classes by using LINQ to SQL based on the records shown in the exhibit:

You need to create a LINQ query to retrieve a list of objects that contains the OrderID and CustomerID
properties.
You need to retrieve the total price amount of each Order record. What are two possible ways to achieve
this goal?
(Each correct answer presents a complete solution. Choose two.)
The application connects to a Microsoft SQL Server 2008 database.
You create classes by using LINQ to SQL based on the records shown in the exhibit:

You need to create a LINQ query to retrieve a list of objects that contains the OrderID and CustomerID
properties.
You need to retrieve the total price amount of each Order record. What are two possible ways to achieve
this goal?
(Each correct answer presents a complete solution. Choose two.)
正解:B、D
解答を投票する
解説: (JPNTest メンバーにのみ表示されます)
You use Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server
2008 database.
The application includes a table adapter named taStore, which has the following DataTable.

There is a row in the database that has a ProductID of 680. You need to change the Name column in the
row to "New Product Name".
Which code segment should you use?
2008 database.
The application includes a table adapter named taStore, which has the following DataTable.

There is a row in the database that has a ProductID of 680. You need to change the Name column in the
row to "New Product Name".
Which code segment should you use?
正解:C
解答を投票する
解説: (JPNTest メンバーにのみ表示されます)
You use Microsoft .NET Framework 4 to develop an application that connects to a Microsoft SQL Server
2008 database.
You add the following stored procedure to the database.
CREATE PROCEDURE [dbo].[InsertTag] @Name nvarchar (15)
AS INSERT INTO [dbo].[Tags] (Name) VALUES(@Name) RETURN @@ROWCOUNT
You need to invoke the stored procedure by using an open SqlConnection named conn. Which code segment should you use?
2008 database.
You add the following stored procedure to the database.
CREATE PROCEDURE [dbo].[InsertTag] @Name nvarchar (15)
AS INSERT INTO [dbo].[Tags] (Name) VALUES(@Name) RETURN @@ROWCOUNT
You need to invoke the stored procedure by using an open SqlConnection named conn. Which code segment should you use?
正解:C
解答を投票する
解説: (JPNTest メンバーにのみ表示されます)
You use Microsoft Visual Studio 2010 and .NET Framework 4.0 to enhance and existing application use
Entity Framework.
The classes that represent the entites in the model are Plain old CLR Object (POCO) Classes.
You need to connect the existing POCO classes to an entity framework context. What should you do?
Entity Framework.
The classes that represent the entites in the model are Plain old CLR Object (POCO) Classes.
You need to connect the existing POCO classes to an entity framework context. What should you do?
正解:D
解答を投票する
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?
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?
正解:D
解答を投票する
解説: (JPNTest メンバーにのみ表示されます)
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application.
You use the ADO.NET Entity Data Model (EDM) to define a Customer entity.
You need to add a new Customer to the data store without setting all the customer's properties. What
should you do?
You use the ADO.NET Entity Data Model (EDM) to define a Customer entity.
You need to add a new Customer to the data store without setting all the customer's properties. What
should you do?
正解:D
解答を投票する
解説: (JPNTest メンバーにのみ表示されます)
You use Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server
2008 database.
You need to ensure that the application connects to the database server by using SQL Server
authentication.
Which connection string should you use?
2008 database.
You need to ensure that the application connects to the database server by using SQL Server
authentication.
Which connection string should you use?
正解:C
解答を投票する
解説: (JPNTest メンバーにのみ表示されます)
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 define a Category class by writing the following code segment. (Line numbers are included for
reference only.)
01 public class Category
02 {
03 public int CategoryID { get; set; }
04 public string CategoryName { get; set; }
05 public string Description { get; set; }
06 public byte[] Picture { get; set; }
07 ...
08 }
You need to add a collection named Products to the Category class. You also need to ensure that the
collection supports deferred loading.
Which code segment should you insert at line 07?
The application uses the ADO.NET Entity Framework to model entities.
You define a Category class by writing the following code segment. (Line numbers are included for
reference only.)
01 public class Category
02 {
03 public int CategoryID { get; set; }
04 public string CategoryName { get; set; }
05 public string Description { get; set; }
06 public byte[] Picture { get; set; }
07 ...
08 }
You need to add a collection named Products to the Category class. You also need to ensure that the
collection supports deferred loading.
Which code segment should you insert at line 07?
正解:C
解答を投票する
解説: (JPNTest メンバーにのみ表示されます)
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 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 context = new AdventureWorksEntities())
02 {
03 ...
04 foreach (SalesOrderHeader order in customer.SalesOrderHeader)
05 {
06 Console.WriteLine(String.Format("Order: {0} ",
order.SalesOrderNumber));
07 foreach (SalesOrderDetail item in order.SalesOrderDetail)
08 {
09 Console.WriteLine(String.Format("Quantity: {0} ", item.Quantity));
10 Console.WriteLine(String.Format("Product: {0} ",
item.Product.Name));
11 }
12 }
13 }
You want to list all the orders for a specific customer. You need to ensure that the list contains following fields:
-Order number
-Quantity of products
-Product name
Which code segment should you insert in line 03?
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 context = new AdventureWorksEntities())
02 {
03 ...
04 foreach (SalesOrderHeader order in customer.SalesOrderHeader)
05 {
06 Console.WriteLine(String.Format("Order: {0} ",
order.SalesOrderNumber));
07 foreach (SalesOrderDetail item in order.SalesOrderDetail)
08 {
09 Console.WriteLine(String.Format("Quantity: {0} ", item.Quantity));
10 Console.WriteLine(String.Format("Product: {0} ",
item.Product.Name));
11 }
12 }
13 }
You want to list all the orders for a specific customer. You need to ensure that the list contains following fields:
-Order number
-Quantity of products
-Product name
Which code segment should you insert in line 03?
正解:A
解答を投票する