开发者

Is it possible to override the .InsertOnSubmit(entity) function to add functionality

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);
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜