在signalr中是否有替换Sql依赖的Top?

时间:2015-09-03 09:07:24

标签: sql signalr sqldependency

请告诉我如何在sql依赖中使用Top或其他sql语句获取前5条记录,每当我使用它时,它总是显示Sql NotificationType Subscribe。

请帮助我使用SignalR中的查询获取最佳记录

当我尝试这个时它工作正常

public void SendStocksNotifications(string symbol="")
        {
            string conStr = ConfigurationManager.AppSettings["myConnectionString"].ToString();
            using (var connection = new System.Data.SqlClient.SqlConnection(conStr))//"data source="";initial catalog="";persist security info=True;user id="";password="";multipleactiveresultsets=True;application name=EntityFramework""))
            {
                string newdate = DateTime.Now.ToString( "MM/dd/yyyy" );
                string query = "SELECT TOP 1 [Close],Pre_Close, Volume, Pre_Volume, PercentageChange, Pre_PercentageChange, NetChange, Pre_NetChange, High, Low, Pre_High, Pre_Low,Previous, Pre_Previous, [52WH], [52WL] FROM [dbo].[History] WHERE Symbol='" + symbol + "' ORDER BY UpdatyedDate DESC";
                 connection.Open();
                 using ( SqlCommand command = new SqlCommand( query, connection ) )
                 {

                 }
        }
    }

但是这段代码

private void dependency_OnChange1(object sender, SqlNotificationEventArgs e)
    {
        if (e.Type == SqlNotificationType.Change)
        {
            string symbol = Vsymbol;
            NotificationStocks nHub = new NotificationStocks();
            nHub.SendStocksNotifications( symbol );
        }

    }
shows e.Type=SqlNotificationType.Subscribe.

0 个答案:

没有答案