可用的框架/工具来发送更改通知?

发布于 2024-11-15 00:21:06 字数 366 浏览 7 评论 0原文

是否有一个框架可以识别(通过比较对象)对象属性值何时发生更改(用户可以指定要“监视”的属性),然后引发事件/发送通知?

示例:应用程序将 Person 类存储在数据库中,并在内存中保留一个副本。该应用程序从数据库中检索人员数据,以定期刷新内存中的副本。其他应用程序/进程更新数据库中的人员数据。我希望当人对象的情绪属性(字符串列表集合:乐观,疲倦等)更改时引发事件/通知。

我知道如何编写此代码,但我感觉有一些东西可以做到这一点。我能想到的只有两件事是相似的:

  • 缓存通知,但还没有看到任何允许您指定哪个 要通知的属性/值。这还需要一个分布式缓存服务器。

  • sql 查询通知 - 我正在研究这个。

Is there a framework that will identify (through comparing the object) when an object property value has changed (user can specify which properties to "watch") and then raise an event/send a notification?

Example: The app stores Person class in a database and keeps a copy in memory. The app retrieves the person data from the database to refresh the copy in memory periodically. Other apps/processes update the person data in the database. I want an event/notification raised when the mood property(list collection of strings: Upbeat,tired, etc.) of the person object is changed.

I know how to code this, but I get the feeling there is something out there that does this. Only two things I can think of that is similar is:

  • cache notifications, but haven't seen any that allow you to specify which
    properties/values to notify on. This would also require one to have a distributed cache server.

  • sql query notifications - I'm looking into this one.

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

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

发布评论

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

评论(1

柳若烟 2024-11-22 00:21:06

您对问题的描述听起来很像您使用实体框架(和其他 ORM)时发生的情况。您可以使用实体框架,并在处理对象后检查对象以检测更改。您可以在此处找到示例。

这是您正在寻找的东西吗?

编辑:

关于 Sql 查询通知,请查看 SqlDependency Class(如果您想沿着这条路线走下去)。

Your description of the issue sounds a lot like what happens when you work with Entity Framework (and other ORMs). It's possible you could use the Entity Framework, and inspect the objects after they have been processed to detect changes. An example of which you can find here.

Is that the kind of thing you're looking for?

EDIT:

Regarding the Sql Query Notifications, take a look at the SqlDependency Class if you want to head down that route.

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