[英]Automatically load newly inserted rows (SQL Server database) in ASP.NET webforms front-end?
I have a SQL Server database with one table and I am doing operations using Entity Framework 6 in C#.我有一个带有一张表的 SQL 服务器数据库,我正在 C# 中使用 Entity Framework 6 进行操作。
I have a jQuery in my frontend which calls a method in the C# backend and loads the data from the database using Entity Framework.我的前端有一个 jQuery,它调用 C# 后端中的一个方法,并使用 Entity Framework 从数据库加载数据。
Now I want to invoke this method automatically as soon my table in database gets any new rows / data.现在我想在数据库中的表获取任何新行/数据时自动调用此方法。
I don't want to use SignalR, wants to keep it simple as possible.我不想使用 SignalR,希望尽可能简单。
I am still figuring out the best possible and easiest way to do this.我仍在寻找最好和最简单的方法来做到这一点。 If I add a trigger on my table in SQL Server, then how it will invoke my jQuery method or C# method?如果我在 SQL 服务器的表上添加触发器,那么它将如何调用我的 jQuery 方法或 C# 方法?
If I add a trigger on my table in SQL Server, then how it will invoke my jQuery method or C# method?如果我在 SQL 服务器的表上添加触发器,那么它将如何调用我的 jQuery 方法或 C# 方法?
It can't, at least not directly, without implementing something poorly like a CLR procedure that then invokes your application.它不能,至少不能直接实现,除非实现一些糟糕的东西,比如 CLR 过程,然后调用您的应用程序。
You can look into Query Notifications to potentially accomplish your goals in a more vanilla way, but be warned, you'll probably be the only person in existence actively using this feature:您可以查看查询通知以更普通的方式实现您的目标,但请注意,您可能是唯一一个积极使用此功能的人:
Built upon the Service Broker infrastructure, query notifications allow applications to be notified when data has changed.查询通知建立在 Service Broker 基础设施之上,允许应用程序在数据发生变化时得到通知。 This feature is particularly useful for applications that provide a cache of information from a database, such as a Web application, and need to be notified when the source data is changed.此功能对于提供数据库信息缓存的应用程序特别有用,例如 Web 应用程序,并且需要在源数据更改时得到通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.