I'm curious what would be the best practice for using the DataAccesAdapter.
Would be this class design acceptable ? The class is used in a windows service application.
public class CustomerService
{
private IDataAccessAdapter dataAccessAdapter;
public CustomerService(IDataAccessAdapter dataAccessAdapter)
{
this.dataAccessAdapter = dataAccessAdapter;
}
public CustomerEntity GetItem(int Id)
{
var customer = new CustomerEntity(Id);
this.dataAccessAdapter.FetchEntity(customer);
return customer;
}
public EntityCollection<CustomerEntity> GetList()
{
var coll = new EntityCollection<CustomerEntity>();
this.dataAccessAdapter.FetchEntityCollection(coll,null);
return coll;
}
}
I looked up in the doc, but there isn't much info about how dataaccessadapter is working behind the scenes.
I saw often this pattern
public CustomerEntity GetItem(int Id)
{
var customer = new CustomerEntity(Id);
using(var adapter = new DataAccessAdapter())
{
adapter.FetchEntity(customer);
}
return customer;
}
but when there gonna be like 10 - 15 method in the class, the code would starts get messy.