
332Microsoft Visual Studio 2010: A Beginner’s Guide
wanted to see the changes that were made, you could call the GetCustomer method again, like this:
C#:
Customer updatedCust = svc.GetCustomer(cust.CustomerID);
VB:
Dim updatedCust As Customer
updatedCust = svc.GetCustomer(cust.CustomerID)
Similarly, you can delete a Customer, as follows:
C#:
svc.DeleteCustomer(updatedCust.CustomerID);
VB:
svc.DeleteCustomer(updatedCust.CustomerID)
As in the previous example, we use the service proxy reference to call the DeleteCustomer method, passing in an ID from the updated customer. The updatedCust reference was from the previous call to GetCustomer. If you wanted to get all of the Customer records from the Web service, you could call GetCustomers, like this:
C#:
Customer[] customers = svc.GetCustomers();
VB:
Dim customers As Customer() customers = svc.GetCustomers()
While this is similar to other method calls in previous examples, you might notice that the return value from GetCustomers here is an array of Customer, Customer[] (Customer() in VB). However, the Web service defined GetCustomers as returning a List of Customer, List<Customer> (List(Of Customer) in VB), as specified in the ICustomerService interface in Listing