This post was prompted from a forum thread in which the user wanted to display database errors in a Dynamic Data page, instead of the default behavior that ends up with an unhandled exception (or an AJAX error with partial rendering). When using Linq To Sql, this can be done fairly easily in a couple different ways, by wrapping the exception in a ValidationException. To do it globally for a DataContext, you can do something like this: public override void SubmitChanges(System.Data.Linq. ConflictMode failureMode) { try { base .SubmitChanges(failureMode); } catch ( Exception e) { throw new ValidationException ( null , e); } } And to do it with more granularity, you can use one of the partial methods on the DataContext. e.g. partial...(read more) ...
Go to the complete details ...