306Microsoft Visual Studio 2010: A Beginner’s Guide
We started customizing the contract when changing the name of IService1 to ICustomerService, but we need to continue by defining the methods that will become part of the CustomerService contract: GetCustomers, GetCustomer, InsertCustomer, UpdateCustomer, and DeleteCustomer. In practice, there will be more methods you’ll want, just to customize the contract for the special needs of your application, but these methods depict typical scenarios you’ll frequently encounter and are representative of any work you’ll perform. Listing
Listing 11-2 WCF service contract implementation
C#:
[ServiceContract]
public interface ICustomerService
{
[OperationContract]
Customer GetCustomer(int custID);
[OperationContract] List<Customer> GetCustomers();
[OperationContract]
int InsertCustomer(Customer cust);
[OperationContract]
void UpdateCustomer(Customer cust);
[OperationContract]
void DeleteCustomer(int custID);
}
VB:
<ServiceContract()>
Public Interface ICustomerService
<OperationContract()>
Function GetCustomer(ByVal custID As Integer) As Customer
<OperationContract()>
Function GetCustomers() As List(Of Customer)