Automatically load newly inserted rows (SQL Server database) in ASP.NET webforms front-end?

ccrfmcuu  于 2022-12-10  发布在  SQL Server
关注(0)|答案(1)|浏览(107)

I have a SQL Server database with one table and I am doing operations using Entity Framework 6 in C#.
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.
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.
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?

kkbh8khc

kkbh8khc1#

If I add a trigger on my table in SQL Server, then how it will invoke my jQuery method or C# method?
It can't, at least not directly, without implementing something poorly like a CLR procedure that then invokes your application.
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. 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.

相关问题