IsNemoEqualTrue/monitor-table-change-with-sqltabledependency

Any plans to use Microsoft.Data.SqlClient?

spareilleux opened this issue · 4 comments

Microsoft is providing a new package for SQLclient types

https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/

By any chance, is there any plans to use the new NuGet package?

Thanks

HI
Yes, it is a GOOD suggestion.
I will do in the next days.
Thanks!

Hi Stephane
i spent some time to introduce Microsoft.Data.SqlClient.
When SqlTableDependency reference Microsoft.Data.SqlClient (and not anymore System.Data.SqlClient), it works. However, using .net framework application throws the following exception: Could not load file or assembly 'Microsoft.Data.SqlClient'.

If you have a working solution, i will be glad to apply. Otherwise i will keep using System.Data.SqlClient.

it that possible default System.Data.SqlClient, but can new Microsoft.Data.SqlClient like this ?

        public static IGlobalConfiguration<SqlServerStorage> UseSqlServerStorage([NotNull] this IGlobalConfiguration configuration, [NotNull] Func<DbConnection> connectionFactory, [NotNull] SqlServerStorageOptions options)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (connectionFactory == null)
            {
                throw new ArgumentNullException("connectionFactory");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            SqlServerStorage storage = new SqlServerStorage(connectionFactory, options);
            return configuration.UseStorage(storage);
        }
            services.AddHangfire(configuration => configuration
                .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
                .UseSimpleAssemblyNameTypeSerializer()
                .UseRecommendedSerializerSettings()
                .UseSqlServerStorage(() => new Microsoft.Data.SqlClient.SqlConnection(Configuration.GetConnectionString("HangfireConnection")), new SqlServerStorageOptions
                {
                    CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
                    SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
                    QueuePollInterval = TimeSpan.Zero,
                    UseRecommendedIsolationLevel = true,
                    DisableGlobalLocks = true
                }));
xsacha commented

Still unresolved?