This project has moved and is read-only. For the latest updates, please go here.

Please review this design, maybe IUnitOfWork is flawed

Topics: Developer Forum
Oct 9, 2006 at 12:15 AM
All the code that call a member of IUnitOfWork know at design-time the entity type of the arguments and the return types. Nevertheless a call at run-time to a member of IUnitOfWork can result in an InvalidCastException.

This can be improved coming to a complete compile-time type check.
Something like this:

class NorthwindEntitiesUnitOfWork
{
public IList<Customer> GetAllCustomers() {
// ...
}

public IList<Product> GetAllProducts() {
// ...
}

// ...
}


Do you see any reason to have a generic IUnitOfWork that don't know the northwind db entities?


Oct 9, 2006 at 12:49 AM
More on this, I feel that it is not a responsability of UnitOfWork the persistence opertions to/from the db.

The responsability of UnitOfWork should be to coordinate reading and writing of all object instances involved in the same bussiness transaction.

IMO the persistence operazions should be placed i.e. in CustomerPersistenceService.cs (ManagedDesign.Northwind assembly).