GithubHelp home page GithubHelp logo

vany0114 / signalr-core-sqltabledependency Goto Github PK

View Code? Open in Web Editor NEW
37.0 9.0 19.0 3.16 MB

Shows how the new SignalR Core works with hubs and sockets, also how it can integrate with SqlTableDependency API.

Home Page: http://elvanydev.com

License: MIT License

C# 55.01% JavaScript 1.48% CSS 4.69% HTML 38.82%
signalr signalr-core signalrcore signalr-client asp-net-core netcore netcore2 netcore-2 sqltabledependency entity-framework

signalr-core-sqltabledependency's Introduction

SignalR Core and SqlTableDependency

Is very early to talk about SignalR Core but it's exciting too. With the recent releasing of .netcore 2.0 the last Microsoft Build we can test a lot of great improvements and new features, between of them, the new SignalR Core. (Or at least the aproximation of what the SignalR team wants to build.) I have to warning that SignalR Core is on development process right now (as a matter of fact, while I was doing this demo I faced some issues because of the constant upgrades of SignalR team), so a bunch of things could change, but in some months (6 months at least) we can compare the progress and we could have a stable version of SignalR Core, meanwhile we can enjoy of this "version".

Prerequisites and Installation Requirements

Instructions

  1. Clone this repository.
  2. Compile it.
  3. In order to use the SQL Broker, you must be sure to enable Service Broker for the database. You can use the following command: ALTER DATABASE MyDatabase SET ENABLE_BROKER
  4. Create Products table:
CREATE TABLE [dbo].[Products](
	[Name] [varchar](200) NOT NULL,
	[Quantity] [int] NOT NULL,
 CONSTRAINT [PK_Products] PRIMARY KEY CLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
  1. Execute the SignalRCore.Web project.
  2. Execute the SignalRCore.CommandLine project. You can use dotnet run command.

Support

If you find this project helpful you can support me!

Visit my blog http://elvanydev.com/ to view the whole post about SignalR Core.

signalr-core-sqltabledependency's People

Contributors

vany0114 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

signalr-core-sqltabledependency's Issues

Couple thoughts

I understand the need of EF factory, but is it really neccessary in Core version?
Isn’t simpler to use built in scope factory and default EF core scope lifetime.
So every time the shorter than request (or longer) is required use:

using(var scope = scopeFactory.CreateScope())
{
   var context = scope.ServiceProvider.GetRequiredService<DbContext>();
}

This should result with exactly the same purpose, but will allow greater flexibility with sharing context between different repositories for transactions.

Another thing is related about finalizer inside subscription code. You should never use it unless there are unmanaged resources. Here is great article about this:
https://ericlippert.com/2015/05/18/when-everything-you-know-is-wrong-part-one/

Third one: why scoped IHubContext. Why scoped. As far as I know it is by default singleton. So why to change it?

ould not load file or assembly 'System.Data.SqlClien

Awesome tutorial thanks, I get this exception when trying to initilise the TableDependency object
Object:

System.IO.FileLoadException: 'Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

Also get this warning in NuGet dependencies:

Package 'SqlTableDependency 6.1.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.

Signal R error

Hello El Vany

I downloaded the project and tried it out. After making a few adjustments, the SignlaRCore.Web project runs successfully. However, when I click on the sell button, I am receiving a javascript error - Cannot send data if the connection is not in the 'Connected' State.
at c.HttpConnection.send (signalr-client-1.0.0-alpha2-final.min.js:1)
at signalr-client-1.0.0-alpha2-final.min.js:1
at new Promise ()
at c.HubConnection.invoke (signalr-client-1.0.0-alpha2-final.min.js:1)

When the page loads, it does say connection opened. I tried a lot but am not able to resolve this. Can you please let me know what the issue could be? Thanks

Invalid object name sys.login_token

Hi,

Thanks for your netcore20 sample. I created a sample database on my azure sql server. On launch of the SignalCore.Web I get that exception

System.Data.SqlClient.SqlException
HResult=0x80131904
Message=Invalid object name 'sys.login_token'.
Source=Core .Net SqlClient Data Provider
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at TableDependency.SqlClient.SqlTableDependency1.CheckIfUserHasPermissions(String connectionString)
at TableDependency.TableDependency1..ctor(String connectionString, String tableName, IModelToTableMapper1 mapper, IUpdateOfModel`1 updateOf, ITableDependencyFilter filter, DmlTriggerType dmlTriggerType, Boolean executeUserPermissionCheck)
at SignalRCore.Web.Hubs.InventoryDatabaseSubscription.Configure(String connectionString) in C:\Source\VSTS\SignalR-Core-SqlTableDependency\src\SignalRCore.Web\Hubs\InventoryDatabaseSubscription.cs:line 30
at SignalRCore.Web.ApplicationBuilderExtensions.UseSqlTableDependency[T](IApplicationBuilder services, String connectionString) in C:\Source\VSTS\SignalR-Core-SqlTableDependency\src\SignalRCore.Web\Extensions\ApplicationBuilderExtensions.cs:line 15
at SignalRCore.Web.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in C:\Source\VSTS\SignalR-Core-SqlTableDependency\src\SignalRCore.Web\Startup.cs:line 76
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.ApplicationInsights.HostingStartup.ApplicationInsightsLoggerStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder builder)
at Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at SignalRCore.Web.Program.Main(String[] args) in C:\Source\VSTS\SignalR-Core-SqlTableDependency\src\SignalRCore.Web\Program.cs:line 21

Hope you can help me
best
Eric

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.