I have a desktop project in C# .NET that is structured in: gui, business and data access layers. Each business layer class represent an entity of the database. I am using linq to access the database. But the the way the project is implemented today does not allow to make many operations atomically, and i need this to be done in business layer.
I searched to some design patterns and found unitOfWork that makes all operation in data layer in the same context and after all the changes are submitted. This would work to make the operations atomic. But the problem is that the operations I want to do need to be validated before, that means, instead of calling a method from data layer i need to call a method from business layer to be validated before. This call in the business layer would create another unitOfWork and, consequently, create another context breaking the atomicity of the bigger operation I am trying to do.
The question is: What the best project pattern to call one or more methods of the business layer from the business layer in the same linq context?
One way of doing it would be: