使用 net.tcp 通信和 silverlight 推送数据库更改的最佳方式
使用 net.tcp 通信将数据库更改推送到 silverlight ui 的最佳方法是什么? SQL 通知?查询通知、clr 触发器?或者只是每隔几秒轮询一次数据库? net.tcp 是解决方案吗?
What is the best way to push database changes to silverlight ui using net.tcp communications? Sql Notifications? query notifications, clr triggers? or just poll the database every so many seconds?? And would net.tcp be the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅我对一个非常类似问题的回答此处。基本上,这完全取决于您的需求。最简单的方法是轮询数据库。如果时间和/或性能和/或复杂性并不重要,这可能会满足您的需求。但如果您需要更具可扩展性的解决方案,那么您可能需要使用 SqlDependency 对象之类的东西。
一旦您知道哪些数据已更改,那么您可能会通过 Net.TCP 或 HttpPollingDuplex 绑定向客户端发送通知。
一旦客户端收到通知,您就需要在通知和 UI 后面的模型和/或视图模型之间实现一个转换层。这里没有什么特殊的魔法,只是一些仔细的编码以确保一切保持同步。
更新模型/视图模型后,您最终将到达 XAML 数据绑定显示其价值的阶段,但不幸的是,这只是解决方案的最后一部分。
See my answer to a very similar question here. Basically, it all depends on what your needs are. The simplest way would be to just poll the database. That may meet your needs if timing and/or performance and/or complexity aren't critical. But if you need a more scalable solution, then you probably want to use something like a SqlDependency object.
Once you know what data has changed, then yes, you would presumably send out notifications to the clients over a Net.TCP or HttpPollingDuplex binding.
And once the client has received its notification, then you'll need to implement a translation layer between the notification and the model and/or view model that's sitting behind the UI. There's no special magic here, just some careful coding to make sure that everything stays in sync.
Once the model/viewmodel is updated, you'll finally get to the point where XAML databinding will show its value, but unfortunately, that's only the last part of the solution.