Asp.Net信号R - 检测数据库中的变化? Asp.net Web窗体 [英] Asp.Net Signal R - Detect Changes in Database ? Asp.net Web Forms
问题描述
所以我有一个更新面板内的列表视图
So I have a List View inside an Update Panel
Update Panel
List View
Email 1
Email 2
Email 3
...
我试图做同样的GMAIL ASP.NET中的收件箱中,只有我与挣扎是如何检测数据库的更改(例如,当发送新信息)和Push该消息到ListView中模拟用户收到新邮件(就像Gmail并)
I'm trying to do an inbox similar to GMAIL in ASP.NET, the only I'm struggling with is how to detect DataBase Changes (ie when a new message is sent) and Push that message into the ListView to simulate that the user has received a new message (just like gmail does)
我如何使用SignalR检测数据库更改以及使用SignalR它们推入列表视图?这可能吗?
How do I use SignalR to detect database changes and push them into the List View using SignalR? Is it possible?
推荐答案
如果您正在使用SQL Server请点击此链接。的http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency
If you are using Sql Server follow this link. http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency
基本上,它使用的SqlDependency 认购改变SQL Server中。
It basically uses SqlDependency to subscribe changes in Sql Server.
如果您不使用SQL Server,你必须手动完成。而对于视图方面,你可以使用KnockoutJS或anngular轻松名单进行修改。
If you aren't using Sql Server you have to do this manually. And for view side you can use KnockoutJS or anngular for easy list modification.
//Set up dependency
protected void Application_Start()
{
//...
SqlDependency.Start(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
}
protected void Application_End()
{
SqlDependency.Stop(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
}
SqlDependency dependency = new SqlDependency(command);
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
这篇关于Asp.Net信号R - 检测数据库中的变化? Asp.net Web窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!