Tag: dataprovider

C#:Services访问运行sql语句的dataprovider类 – 正确的方法?

这是一种常见的和/或好的方法吗? 在我的ViewModel(Wpf)或Presenter(WinForms)中,我这样做: ICustomerService customerService = MyService.GetService(); ICustomerList customerList = customerService.GetCustomers(); CustomerService类如下所示: public class CustomerService : ICustomerService { public ICustomerList GetCustomers() { return _customerDataProvider.GetCustomers(); } } public class CustomerDataProvider() { public ICustomerList GetCustomers() { // Open SQL connection, // get back a SqlDataReader and iterate it // in the loop write all data into a ICustomer […]