我正在尝试将Signalr与sqldependency一起使用。我用:
进行了测试select ACTION_DATE,Id,Type_ID,Customer_ID, Phone, Message, User_ID,
Status_ID,CREATED_ON,Description from [TLS].[Notification] where user_id='"
+ Parameters.UserID + "'"
一切正常,当我在db中更改某些内容时,事件触发。
但是当我尝试使用Left join时,我的On_Change
事件不会触发:
select c.DISPLAY_NAME as CustomerName, n.ACTION_DATE,n.Id,n.Type_ID,
n.Customer_ID, n.Phone, n.Message, n.User_ID,
n.Status_ID,n.CREATED_ON,n.Description
from [TLS].[Notification] AS n Left outer join [TLS].[Customer] AS c
on c.ID=n.CUSTOMER_ID
where user_id='" + Parameters.UserID + "' and n.STATUS_ID<>'3'
这是我的方法
var messages = new List<SqlDataReader>();
using (var connection = new SqlConnection(_dbContext.Database.Connection.ConnectionString))
{
connection.Open();
using (var command = new SqlCommand(query, connection))
{
command.Notification = null;
var dependency = new SqlDependency(command);
var reader = command.ExecuteReader();
dependency.OnChange += new OnChangeEventHandler(SqlNotification.dependency_OnChange);
return _dbContext.Database.SqlQuery<T>(query);
}
}