.NET Core 是否支持 SqlDependency? [英] Is SqlDependency supported in .NET Core?

查看:34
本文介绍了.NET Core 是否支持 SqlDependency?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 .NET Core v1.1 应用程序中利用 System.Data.SqlClient.SqlDependency?System.Data.SqlClient 中的大多数其他类和方法似乎都可用,但 SqlDependency 除外.

Is it possible to leverage System.Data.SqlClient.SqlDependency from within a .NET Core v1.1 application? It appears that most of the other classes and methods within System.Data.SqlClient are available except SqlDependency.

本质上,我试图在表数据更改时订阅 SQL 通知,然后更新客户端的 UI,因此,如果 .NET Core 无法使用 SqlDependency,我愿意采用其他方法来实现此目的.

Essentially, I'm trying to subscribe to SQL notifications when table data changes to then update the client's UI, so I'm open to other ways to achieve this if SqlDependency is not available from .NET Core.

提前致谢!这是我完整的 project.json 文件:

Thanks in advance! Here's my complete project.json file:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Authentication": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "System.IdentityModel.Tokens.Jwt": "5.0.0",
    "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Google": "1.0.0",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0",
    "Microsoft.Extensions.Configuration.Binder": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Identity": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Rewrite": "1.0.0",
    "Microsoft.AspNetCore.ResponseCompression": "1.0.0",
    "Microsoft.AspNetCore.SignalR.Server": "0.2.0-*",
    "Microsoft.AspNetCore.WebSockets": "0.2.0-*"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netstandard1.1": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8",
        "net461",
        "dnxcore50"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "Views",
      "wwwroot",
      "appsettings.json",
      "appsettings.dev.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

推荐答案

GitHub 上提供了一个基于 .Net Core 的开源解决方案:https://github.com/dyatchenko/ServiceBrokerListener

There's a .Net Core based open source solution available on GitHub : https://github.com/dyatchenko/ServiceBrokerListener

但是,我不确定性能,因为似乎多个客户端应用程序侦听更改正在创建专用队列.因此,它的扩展性可能不如原始的 SqlDependency.

I'm not sure about the performance however, because it seems that the multiple client-app listening for changes are creating dedicated queues. So maybe it doesn't scale as good as the original SqlDependency.

这篇关于.NET Core 是否支持 SqlDependency?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆