SlideShare a Scribd company logo
SIGNALR &
SQL DEPENDENCY
Bart Callaerts
HOW WE DID IT IN THE PAST
We used to implement a polling system
Client Server
Got new Data ?
Got new Data ?
Got new Data ?
Got new Data ?
Here is new data
Got new Data ?
Got new Data ?
Got new Data ?
Got new Data ?
WHAT IS SIGNALR ?
ASP.NET SignalR is
•Library that makes developping real-time web functionality easy
•Allows bi-directional communication between server and client
•Server can push content to connected clients instantly
•Supports websockets and falls back to other compatible techniques for older
browsers
SQL DEPENDENCY
• A sql dependency object can be associated with a sql command in order to detect
when query results differ from those originally retrieved.
• Assign a delegate to the OnChange event, which will fire when the results change
for an associated command.
SignalR & SQL Dependency
LIMITATIONS FOR SQL DEPENDENCY
Query notifications are supported for SELECT statements that meet the following requirements:
•The projected columns in the SELECT statement must be explicitly stated, and table names must be qualified with two-
part names. Notice that this means that all tables referenced in the statement must be in the same database.
•The statement may not use the asterisk (*) or table_name.* syntax to specify columns.
•The statement may not use unnamed columns or duplicate column names.
•The projected columns in the SELECT statement may not contain aggregate expressions unless the statement uses a
GROUP BY expression. When a GROUP BY expression is provided, the select list may contain the aggregate functions
COUNT_BIG() or SUM(). However, SUM() may not be specified for a nullable column. The statement may not specify
HAVING, UBE, or ROLLUP.
•The statement must not reference a view.
•The statement must not contain any of the following: DISTINCT, COMPUTE or COMPUTE BY, or INTO.
•The statement must not reference tables or views from other databases or servers.
•The statement must not contain subqueries, outer joins, or self-joins.
•The statement must not use any of the following aggregate functions: AVG, COUNT(*), MAX, MIN, STDEV, STDEVP, VAR,
or VARP.
•The statement must not contain conditional statements that cannot change and cannot return results (for example,
WHERE 1=0).
…
DEMO ARCHITECTURE : FLIGHT INFO
ASP.Net
webserver
SignalRConnection
Console
application,
hooked on SQL
depdency
Sql Dependency
Flight Info
Administrati
on
SignalRConnection
1
2
3
Client
watching
Flight Info
SignalRConnection
4
Client
watching
Flight Info
4

More Related Content

PPT
Sql tuning guideline
PPTX
Introduction to structured query language (sql) (1)
PDF
The Ultimate Guide to Oracle solaris 11 advanced system administration 1 z0 822
PPT
e computer notes - Producing readable output with i sql plus
PDF
The Ultimate Guide to Oracle web logic server 12c administration i 1z0 133
PPTX
Sub query example with advantage and disadvantages
DOCX
retrieving data using SQL statements
PDF
Autonumber
Sql tuning guideline
Introduction to structured query language (sql) (1)
The Ultimate Guide to Oracle solaris 11 advanced system administration 1 z0 822
e computer notes - Producing readable output with i sql plus
The Ultimate Guide to Oracle web logic server 12c administration i 1z0 133
Sub query example with advantage and disadvantages
retrieving data using SQL statements
Autonumber

What's hot (20)

PPTX
Sql subquery
PPTX
New features of SQL 2012
PPT
Sql Tutorials
PDF
The Ultimate Guide to Oracle solaris 11 installation and configuration essent...
PDF
DIG1108 Lesson 5
PPTX
1. dml select statement reterive data
PPT
Myth busters - performance tuning 101 2007
PPTX
Passing Lists
PPTX
Operators in mule dataweave
PPT
Les01 (retrieving data using the sql select statement)
PPT
Sydney Oracle Meetup - indexes
PDF
Sql cheat-sheet
PPT
Sql DML
PPT
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
PPTX
PPTX
Excel Database Function
PPTX
MySQL index optimization techniques
Sql subquery
New features of SQL 2012
Sql Tutorials
The Ultimate Guide to Oracle solaris 11 installation and configuration essent...
DIG1108 Lesson 5
1. dml select statement reterive data
Myth busters - performance tuning 101 2007
Passing Lists
Operators in mule dataweave
Les01 (retrieving data using the sql select statement)
Sydney Oracle Meetup - indexes
Sql cheat-sheet
Sql DML
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Excel Database Function
MySQL index optimization techniques
Ad

Similar to SignalR & SQL Dependency (20)

PPTX
ADVANCED MODELLING.pptx
PPTX
02 database oprimization - improving sql performance - ent-db
PPTX
Aggregate functions in SQL.pptx
PPTX
SQL.pptx for the begineers and good know
PPT
INTRODUCTION TO SQL QUERIES REALTED BRIEF
PPTX
Aggregate functions in SQL.pptx
DOC
3963066 pl-sql-notes-only
PPTX
Structure query language (sql)
PPTX
Structure Query Language (SQL).pptx
PPTX
Data Query Using Structured Query Language - WITH NOTES.pptx
PPT
Ms sql server ii
PPTX
SQL Commands
PPTX
Introduction to SQL, SQL*Plus
PDF
What's New in DBArtisan and Rapid SQL 2016
PPT
Advanced Sql Training
PDF
Complete SQL Tutorial In Hindi By Rishabh Mishra (Basic to Advance).pdf
PPT
SQL Inteoduction to SQL manipulating of data
DOCX
PPTX
ZekeLabs PLSQL slides
ADVANCED MODELLING.pptx
02 database oprimization - improving sql performance - ent-db
Aggregate functions in SQL.pptx
SQL.pptx for the begineers and good know
INTRODUCTION TO SQL QUERIES REALTED BRIEF
Aggregate functions in SQL.pptx
3963066 pl-sql-notes-only
Structure query language (sql)
Structure Query Language (SQL).pptx
Data Query Using Structured Query Language - WITH NOTES.pptx
Ms sql server ii
SQL Commands
Introduction to SQL, SQL*Plus
What's New in DBArtisan and Rapid SQL 2016
Advanced Sql Training
Complete SQL Tutorial In Hindi By Rishabh Mishra (Basic to Advance).pdf
SQL Inteoduction to SQL manipulating of data
ZekeLabs PLSQL slides
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
A Presentation on Artificial Intelligence
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Machine Learning_overview_presentation.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Big Data Technologies - Introduction.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
Machine Learning_overview_presentation.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)

SignalR & SQL Dependency

  • 2. HOW WE DID IT IN THE PAST We used to implement a polling system Client Server Got new Data ? Got new Data ? Got new Data ? Got new Data ? Here is new data Got new Data ? Got new Data ? Got new Data ? Got new Data ?
  • 3. WHAT IS SIGNALR ? ASP.NET SignalR is •Library that makes developping real-time web functionality easy •Allows bi-directional communication between server and client •Server can push content to connected clients instantly •Supports websockets and falls back to other compatible techniques for older browsers
  • 4. SQL DEPENDENCY • A sql dependency object can be associated with a sql command in order to detect when query results differ from those originally retrieved. • Assign a delegate to the OnChange event, which will fire when the results change for an associated command.
  • 6. LIMITATIONS FOR SQL DEPENDENCY Query notifications are supported for SELECT statements that meet the following requirements: •The projected columns in the SELECT statement must be explicitly stated, and table names must be qualified with two- part names. Notice that this means that all tables referenced in the statement must be in the same database. •The statement may not use the asterisk (*) or table_name.* syntax to specify columns. •The statement may not use unnamed columns or duplicate column names. •The projected columns in the SELECT statement may not contain aggregate expressions unless the statement uses a GROUP BY expression. When a GROUP BY expression is provided, the select list may contain the aggregate functions COUNT_BIG() or SUM(). However, SUM() may not be specified for a nullable column. The statement may not specify HAVING, UBE, or ROLLUP. •The statement must not reference a view. •The statement must not contain any of the following: DISTINCT, COMPUTE or COMPUTE BY, or INTO. •The statement must not reference tables or views from other databases or servers. •The statement must not contain subqueries, outer joins, or self-joins. •The statement must not use any of the following aggregate functions: AVG, COUNT(*), MAX, MIN, STDEV, STDEVP, VAR, or VARP. •The statement must not contain conditional statements that cannot change and cannot return results (for example, WHERE 1=0). …
  • 7. DEMO ARCHITECTURE : FLIGHT INFO ASP.Net webserver SignalRConnection Console application, hooked on SQL depdency Sql Dependency Flight Info Administrati on SignalRConnection 1 2 3 Client watching Flight Info SignalRConnection 4 Client watching Flight Info 4

Editor's Notes

  • #2: Easy to use technique for Server - Client communication In combination with SQL Dependency
  • #6: Initiate a SqlDependency connection to the server. Create SqlConnection and SqlCommand objects to connect to the server and define a Transact-SQL statement. Create a new SqlDependency object, or use an existing one, and bind it to the SqlCommand object. Internally, this creates aSqlNotificationRequest object and binds it to the command object as needed. This notification request contains an internal identifier that uniquely identifies this SqlDependency object. It also starts the client listener if it is not already active. Subscribe an event handler to the OnChange event of the SqlDependency object. Execute the command using any of the Execute methods of the SqlCommand object. Because the command is bound to the notification object, the server recognizes that it must generate a notification, and the queue information will point to the dependencies queue. Stop the SqlDependency connection to the server.
  • #8: Web project: Add nuget package Microsoft.AspNet.SignalR Register the middleware in the startup class Create a Hub class : FligtInfoHub with method UpdateFlightInfoBoard that the console can call I this method a property is found Clients which exposes a dynamic property All on which you can call a method that will be executed on the client side javascript. Javascript Client side SignalR will generate script files on the fly which contain all the methods that will be called by the server On document ready, create a hub on the signalR connection Hook up a function on the hub.Client.updateFlightboardInfo to update the flight info. At the end you need to start the hub, this way the connection is set up between client and server. Console On the trigger of the sql dependency create a HubConnection Create a Hub for this connection with the name of the hub Then start the connection and invoke the method. Demo with breakpoints, Demo without breakpoints