是否可以覆盖.InsertOnSubmit(实体)函数来添加功能(Is it possible to override the .InsertOnSubmit(entity) function to

编程入门 行业动态 更新时间:2024-10-27 20:33:08
是否可以覆盖.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); } }

更多推荐

本文发布于:2023-04-28 00:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329620.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   函数   功能   InsertOnSubmit   override

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!