locked
how to use SignalR with multiple VS projects RRS feed

  • Question

  • User-1760640578 posted

    Whenever data in a SQL table changes I want to use SignalR to show the changes immediately on my user interface (Asp.NET MVC EF6).  So I started researching and found the article below on codeproject.com.  My solution is a little different though because I have multiple projects (WEB, DATA- this project has my repositories, migrations, unit of work, DbContext, etc., SERVICE, MODEL).  In my DATA project I added the repository similar to the example but where I'm stuck is the SQL dependency OnChange method because my Hub is in my web project.  Do I pass the Hub from the web project to the service/repository?  I don't think it makes sense to add SignalR NuGet package to my DATA project.  Can anyone give me some pointers?

    https://www.codeproject.com/Articles/874240/SignalR-Database-update-notifications-in-ASP-NET-M

    Friday, July 27, 2018 8:55 PM

All replies

  • User475983607 posted

    The data access project is either a DLL in the web application or a DLL in a service.  Basically, your question is irrelevant because the executing code is in the web or service project.

    Monday, July 30, 2018 2:22 PM
  • User-1760640578 posted

    Here is my problem.  I have this code in my repository.  MessagesHub does not exist in my repository (DATA) project.  It only exists in the WEB project.  How can I make it work?

            private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
            {
                if (e.Type == SqlNotificationType.Change)
                {
                    //I get an error here because MessagesHub does not exist.  The Hub is inside my web project.  How do I fix this?
                    MessagesHub.SendMessages();
                }
            }



    Monday, July 30, 2018 8:42 PM