266Microsoft Visual Studio 2010: A Beginner’s Guide

{

currentCust.Age = cust.Age; currentCust.Birthday = cust.Birthday; currentCust.Income = cust.Income; currentCust.Name = cust.Name;

}

m_ctx.SubmitChanges();

}

public Customer GetCustomer(int custID)

{

return

(from cust in m_ctx.Customers where cust.CustomerID == custID select cust)

.SingleOrDefault();

}

public List<Customer> GetCustomers()

{

return

(from cust in m_ctx.Customers select cust)

.ToList();

}

public void DeleteCustomer(int custID)

{

var customer =

(from cust in m_ctx.Customers where cust.CustomerID == custID select cust)

.SingleOrDefault();

m_ctx.Customers.DeleteOnSubmit(customer); m_ctx.SubmitChanges();

}

}

}

VB:

Public Class CustomerRepository

Private m_ctx As New MyShopDataContext

Page 289
Image 289
Microsoft 9GD00001 manual Microsoft Visual Studio 2010 a Beginner’s Guide