是否可以覆盖.InsertOnSubmit(实体)函数来添加功能(Is it possible to override the .InsertOnSubmit(entity) function to add functionality)
使用LINQ To SQL插入错误日志,但客户端现在还想要发送每个提交的错误的电子邮件。 是否有可能覆盖DataContext.ErrorLog.InsertOnSubmit函数,以便在调用submit时发送电子邮件而不必更改太多代码? 或者更快更容易做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 DataContext.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?
最满意答案
据我所知,但可以覆盖SubmitChanges
public partial class DataContext { public override void SubmitChanges(System.Data.Linq.ConflictMode failureMode) { var errorLogEntities = GetChangeSet().Inserts.OfType<ErrorLog>(); base.SubmitChanges(failureMode); } }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); } }更多推荐
发布评论