Using LINQ To SQL to insert into an error log, but the client now wants to also send emails on every error that is submitted. Is it possible to override the DataContex开发者_如何学Pythont.ErrorLog.InsertOnSubmit
function to also send an email when submit is called without having to change too much code? Or would it be faster and easier to do the 10 or so code updates to send the error?
Not to my knowledge, but it is possible to override SubmitChanges
public partial class DataContext
{
public override void SubmitChanges(System.Data.Linq.ConflictMode failureMode)
{
var errorLogEntities = GetChangeSet().Inserts.OfType<ErrorLog>();
base.SubmitChanges(failureMode);
}
}
精彩评论