已提交事件

发布于 2024-09-12 08:07:28 字数 176 浏览 1 评论 0原文

我有一个 silverlight 4 ria 应用程序,我想在实体提交到数据库后触发一个事件。我认为我可以使用像

OnCreated() 这样的 dataclassescontext 方法 OnIdChanged()

但它们在提交之前被调用,我只想在将新实体添加到数据库后以及提交 id 更改后触发该事件。

I have a silverlight 4 ria app, and I'd like to fire an event after entities have been submitted to the database. I thought that I could use the dataclassescontext methods like

OnCreated()
OnIdChanged()

but they are called before submitted, and I only want to fire the event once a new entity is added to the db, and once an id change has been submitted.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红ご颜醉 2024-09-19 08:07:28

您可以在数据类上下文中使用名为“InsertX”、“UpdateX”和“DeleteX”的覆盖方法,其中“X”是表的名称。

例如,如果您的实体表名为 Users,则这些方法称为 partial void InsertUser(User instance) 等。这些方法在 SubmitChanges() 阶段调用,并且仅当不存在此类覆盖方法时,才会执行“标准”插入/删除/更新。

编写这些插入/更新/删除重写方法时需要注意几件事。这些记录在 MSDN 上:开发人员在覆盖默认行为中的责任(LINQ to SQL)

You can use override methods called “InsertX”, “UpdateX” and “DeleteX” in your dataclassescontext, where “X” is the name of the table.

For example, if your entity table is called Users, the methods are called partial void InsertUser(User instance) etc. These methods are called during the SubmitChanges() stage, and the “standard” Insert/Delete/Update is only performed if such an override method is not present.

There are several things you need to be aware of when writing these Insert/Update/Delete override methods. Those are documented here on MSDN: Responsibilities of the Developer In Overriding Default Behavior (LINQ to SQL)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文