2 ms·
((e.NewItem as Customer) ?? Customer.NullObject).Save(); Edit: The idea being, you have a sub-class of Customer which implements the Null Object pattern, which
by InclinedPlane 16y ago
((e.NewItem as Customer) ?? Customer.NullObject).Save();
Edit: The idea being, you have a sub-class of Customer which implements the Null Object pattern, which you instantiate through a static member on Customer or a Property method or what-have-you. The great thing about this is that you can tailor the behavior in this situation to whatever you want. Want to throw an exception? Sure, throw whatever exception you want from CustomerNullObject.Save(). Want to log an error and otherwise silently fail? No prob, easy peasy.