<PackageReference Include="System.Data.SqlClient" Version="4.8.0-preview2.19523.17" />

SqlDependency

public sealed class SqlDependency
The SqlDependency object represents a query notification dependency between an application and an instance of SQL Server. An application can create a SqlDependency object and register to receive notifications via the OnChangeEventHandler event handler.
public bool HasChanges { get; }

Gets a value that indicates whether one of the result sets associated with the dependency has changed.

public string Id { get; }

Gets a value that uniquely identifies this instance of the SqlDependency class.

Occurs when a notification is received for any of the commands associated with this SqlDependency object.

public SqlDependency()

Creates a new instance of the SqlDependency class with the default settings.

public SqlDependency(SqlCommand command)

Creates a new instance of the SqlDependency class and associates it with the SqlCommand parameter.

public SqlDependency(SqlCommand command, string options, int timeout)

Creates a new instance of the SqlDependency class, associates it with the SqlCommand parameter, and specifies notification options and a time-out value.

public static bool Start(string connectionString)

Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string.

public static bool Start(string connectionString, string queue)

Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string using the specified SQL Server Service Broker queue.

public static bool Stop(string connectionString)

Stops a listener for a connection specified in a previous Start call.

public static bool Stop(string connectionString, string queue)

Stops a listener for a connection specified in a previous Start call.

public void AddCommandDependency(SqlCommand command)

Associates a SqlCommand object with this SqlDependency instance.