【发布时间】:2010-07-05 18:03:12
【问题描述】:
第一种方法获取客户数据的优势在哪里?
ICustomerService customerService = MyService.GetService<ICustomerService>();
ICustomerList customerList = customerService.GetCustomers();
对比
ICustomerRepository customerRepo = new CustomerRepository();
ICustomerList customerList = customerRepo.GetCustomers();
如果你理解我的问题,你就不会问 MyService 类的实现是怎样的 ;-)
这里是 Repo 的实现...
interface ICustomerRepository
{
ICustomerList GetCustomers();
}
class CustomerRepository : ICustomerRepository
{
public ICustomerList GetCustomers()
{...}
}
【问题讨论】:
标签: c# repository service