且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

数据库中的一些数据更改。如何触发一些C#代码在这些更改上做一些工作?

更新时间:2023-02-03 22:37:31

我只是一个成本和效益的问题,我想至少考虑一下。 '去与#1。这不是你可能认为的交通量。如果你的数据不经常变化,你可以是悲观的,只是抓取一些东西,让你对表变化yay或不。

I'd go with #1. It's not actually as much traffic as you might think. If your data doesn't change frequently, you can be pessimistic about it and only fetch something that gives you a yay or nay about table changes.

如果你设计你的模式


  • 如果您只是添加记录,

  • If you're only adding records, not changing them, then checking the highest id might be enough on a particular table.

如果您要更新所有这些,则可以存储时间戳列和然后查找最大时间戳。

If you're updating them all then you can store a timestamp column and index it, then look for the maximum timestamp.

您可以发送一个查询,查询多个talbes(有效地),并返回更改的表的列表。

And you can send an ubber query that polls multiple talbes (efficiently) and returns the list of changed tables.

这个答案没有什么特别的聪明,我只是想表明#1可能不是糟糕,因为它一开始似乎。

Nothing in this answer is particularly clever, I'm just trying to show that #1 may not be quite as bad as it at first seems.