public static void SaveToDatabase(Customer customer) { customer.Validate(); if(customer.IsValid) { // Code to save to the database } else { throw new DataValidationException(); } }