public interface IRepository<T>
{
T Find(int id);
IList<T> FindAll();
void Remove(T entity);
void Insert(T entity);
void Update(T entity);
}
public interface IOrderRepository:IRepository<Order>
{
IList<Order> FindByCustomer(Customer customer);
}
public class OrderRepository:IOrderRepository
{
private SampleDataContext dataContext;
public OrderRepository()
{
dataContext = new SampleDataContext();
}
public IList<Order> FindByCustomer(Customer customer)
{
dataContext.Orders.Where(o => o.Customer.Id == customer.Id).ToList();
}
public Order Find(int id)
{
return dataContext.Orders.Where(o => o.Id == id).Single();
}
public IList<Order> FindAll()
{
return dataContext.Orders.ToList();
}
// Implement the rest of IRepository<T> members here
}