168 Microsoft Visual Studio 2010: A Beginner’s Guide

The CustomerRepository Class

In this program, we create a class that is solely responsible for working with data. This is a

common pattern, which is called the Repository pattern. The following CustomerRepository

class has a method that returns a list of Customer objects:

C#:
using System.Collections.Generic;
public class CustomerRepository
{
public List<Customer> GetCustomers()
{
var customers = new List<Customer>
{
new Customer
{
FirstName = "Franz",
LastName = "Smith"
},
new Customer
{
FirstName = "Jean "
},
new Customer
{
FirstName = "Wim",
LastName = "Meister"
}
};
return customers;
}
}
VB:
Public Class CustomerRepository
Public Function GetCustomers() As List(Of Customer)
Dim customers As New List(Of Customer) From
{
New Customer With
{
.FirstName = "Franz",
.LastName = "Smith"
},
New Customer With