用于两个应用程序和公共数据库的实体框架
我有两个使用实体框架的应用程序(Web 和桌面应用程序),它们使用通用的 SQL Server 数据库。它们实现了工作单元模式,并将上下文保留在会话或相关线程中。我的问题是当一个应用程序更新数据库上的某些内容时如何更新另一个应用程序的上下文? 举个例子,假设 Windows 服务已向表中添加了一些行。 Web 应用程序上下文如何在插入的同时获取它。
I have two applications(web and a desktop app) that uses entity framework which use a common sql server database. They have unit of work pattern implemented and it keeps the context in the session or in the relevant thread. My question is how to update context of another application when one application updates something on the database ?
As an example let say the windows service has added some row to a table. How can the web application context get that one at the same time it is inserted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Web 应用程序场景中的上下文应该仅根据请求持续。从我看来,您必须从数据库级别将某些内容实现为事件,因为这似乎是常见的地方。这可以使用触发器来完成
。在您的场景中,您应该执行以下步骤(仅执行绘图板场景)
这项工作的重点在于第三点。您可以通过多种方式实现这一目标。替代方案是编写一个服务来轮询另一个服务(接受来自数据库触发器的警报)以检查修改。所以逻辑分离可以像 db -->接受变更通知的服务 -->轮询通知服务的服务 --> 以上在逻辑和理论上都是可行
的,但希望它对您有所帮助,我很想知道您是如何做到这一点的。
Context in scenario of a web application should only last per the request. From what I see, you have to implement something as an event from database level as that seems to be the common place. This can be done using Triggers
In your scenario, you should perform following steps (just doing a drawing board scenario)
The meat of the work lies in the third point. You can achieve it in many ways. Alternatives are writing a service that polls another service (which accepts alerts from db trigger) for checking the modifications. so the logical separation could be like db --> service that accepts the change notification --> service that polls the notification service --> application
Above works logically and theoretically but hope it helps you out and I would be keen to know how you go about doing this.