You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 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, name , address1)
B.
context.ExecuteCommand(“createCustomer”, userID, name , address1);
C.
Customer customer = new Customer() {
ID = userID,
Address1 = address1,
Name = name,
};
context.ExecuteCommand(“createCustomer”, customer);
D.
Customer customer = new Customer() {
ID = userID,
Address1 = address1,
Name = name,
};
context.ExecuteQuery(typeof(Customer), “createCustomer”, customer);
Explanation:
CHAPTER 4 LINQ to SQL
Lesson 3: Submitting Changes to the Database
Using Stored Procedures (page 285)