开发者

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

开发者 https://www.devze.com 2023-03-07 06:10 出处:网络
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.Ins

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

精彩评论

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