I have a validation rule question about the patterns in action application:
Sometimes it's necessary to perform complex validation logic with have a heavy database load cost. Example: A member may only be deleted, when all business related members are deleted. Like: Partner/Consumer principle -> partner cannot be deleted when it has 1 or more consumers. All consumers must be deleted first, before the partner can be deleted.
Where's the best place to put these complex logic in the application? Is it in the business logic layer, but when/how is the best time to load the database data to able to perform the validation logic (it shouldn't be loaded every time a member is loaded)? Or is it the service layer or some where else?
In the patterns in action example could a member only deleted when it has no orders. This validation logic is done in the presentation layer. I think it shouldn't be in the presentation layer because all these logic must be implemented in all presentation layered projects (MVC, Forms, WinForms and WPF). And in addition, if you want to pre-validate before deleting, this functionality should execute the same validation logic of the same code base (to prevent inconsistency between pre-validation and validation logic).
All kind of answers / thoughts are welcome. Thanks in advance,