Skip to content

How to use it with SignalR? #66

@srbhklkrn

Description

@srbhklkrn

I'm trying to use your library and push changes using signalR but it's not triggering the changes any idea why?

getting following error

System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object.

on line _sqlDependency.Start();

public class SignalServer : Hub
    {
        public readonly TestController _testController;
        public IConfiguration Configuration { get; }
        public SqlDependencyEx _sqlDependency;

        public SignalServer(TestController testController, IConfiguration configuration)
        {
            Configuration = configuration;
            _testController = testController;

            SqlDependencyEx _sqlDependency = new SqlDependencyEx(Configuration.GetConnectionString("DefaultConnection"), "PCFStatus", "apps");
        }

        public async void NotifyConnection()
        {
            await Clients.All.SendAsync("TestBrodcasting", _testController.GetAllApps());

             _sqlDependency.Start();

            if (_sqlDependency != null)
            {
                _sqlDependency.TableChanged += OnDataChange;
               
            }
        }

        private async void OnDataChange(object sender, SqlDependencyEx.TableChangedEventArgs e)
        {
            await Clients.All.SendAsync("TestBrodcasting", _testController.GetAllApps());
        }

    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions