I've been debating this in my head for a bit now, and I'm either not clear or I can't remember the logic. Enlighten me, Stack Overflow!
I have a base class called TCOrder. I have a derived class called LPOrder. TCOrder houses CRUD operations, and LPOrder simply flips a few values on some of its properties, then calls the base class methods. We have our standard CRUD:
Create
Update
Delete
Select
I've marked the LPOrder class with a IOrder interface that forces the LPOrder to implement CRUD methods that line up with the base class. Then I inject this object into my repository as such:
OrderRepository oRepo = new OrderRepository(LPOrder);
Inside the OrderRepository, I'm doing the following:
private IOrder _order;
OrderRepository(IOrder order) { _order = order; }
public void Create() {
_order.Create();
}
I can do this cleanly for all the operations that are clearly on a single LPOrder object. I would create, update, and delete an object based on the fields I'm setting in the object itself. Where I struggle is when I call a SelectAll() function of some kind on the LPOrder class.
Technically, I'm not running an operation on a single object anymore. I'm asking for it to return a List where T is IOrder. So, I'm calling a single instance of LPOrder to return a list of all LPOrders based on parameters I set? Does this make sense at all? What have others done in the past?
I would like to house this functionality within the TCOrder itself because it will be hitting a specific service to retrieve data. But I'm having trouble getting my head past the fact that perhaps I'm thinking of TCOrder as a base class, not a base domain?
Aucun commentaire:
Enregistrer un commentaire