Is there a preferable way of when a service should persist data?UpdateDoes this depend on if the services are public or internal?Some services take entity objects as parameters to do some action on that object, update it's status or add some data to it. Should that service also persist changes to that object to the database(SaveChanges, Flush, ...) or should the caller who got/created that entity decide if and when to persist it?Making the inner service persist the data includes problems like: harder tests, can't use implicit database transactions, maybe many database roundtrips instead of one.It is best to describe this with an example:public void PerformAction(int productId, int actionId){    var product = productRepository.GetProduct(productId);    var action = actionRepository.GetAction(actionId);    actionService.PerformAction(product, action);    //Should this be necessary?    productRepository.Update(product);}This would be obvious but then the PerformAction could not have dependencies other than the model:public void PerformAction(int productId, int actionId){    var product = productRepository.GetProduct(productId);    var action = actionRepository.GetAction(actionId);    product.PerformAction(action);    //Obviously necessary!    productRepository.Update(product);}
When should services persist data?
c#;design
If you explicitly save data, the best place to perform that is in a call at the end of the highest level method, the entry point to your service. That means you must divide your service methods into two categories, those that are public, entry level methods, and those that are internal methods, that should not save data.