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?

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?

A.
context.createCustomer(userID, customer1, address1);

B.
context.ExecuteCommand(“createCustomer”, userID, customer1, address1);
Customer customer = new Customer() { ID = userID, Address1 = address1, Name = customer1, };

C.
context.ExecuteCommand(“createCustomer”, customer);
Customer customer = new Customer() { ID = userID, Address1 = address1, Name = customer1, };

D.
context.ExecuteQuery(typeof(Customer), “createCustomer”, customer);

Explanation:
CHAPTER 4 LINQ to SQL
Lesson 3: Submitting Changes to the Database
Using Stored Procedures (page 285)



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Mike

Mike

I think that A should read:
context.createCustomer(userID, name, address1);

John Galt

John Galt

Agreed. It should be ‘name’ instead of ‘customer1’, but both B and C have the same error, so it must be a typo on Microsoft’s part. A is still the right answer.