We added SqlTableDependency on a Table Transaction with a following structure
CREATE TABLE [dbo].[Transaction]( [Id] [bigint] IDENTITY(1,1) NOT NULL, [Value] [decimal](18, 2) NOT NULL )
then we created ModelToTableMapper
var mapper = new ModelToTableMapper<Transaction>(); mapper.AddMapping(s => s.Id, "Id").AddMapping(s => s.Value);
and created new SqlTableDependency
_tableDependency = new SqlTableDependency<Transaction>( ConfigurationManager.ConnectionStrings["defaultConnection"].ConnectionString, "Transaction",mapper); _tableDependency.OnChanged += SqlTableDependency_Changed; _tableDependency.OnError += SqlTableDependency_OnError; _tableDependency.Start();
Up until now everything works fine but then we go and we insert decimal value with two decimal places like on the following screen.
And when we save record we inspect what happens in the SqlTableDependency_Changed event.
If we inspect the inserted value we see that it is not properly formatted and the number is rounded. If I go further and I change the culture of SqlTableDependency to sl-SI
_tableDependency.CultureInfoFiveLettersIsoCode = "sl-SI";
I am still getting the same result -> decimal numbers are without decimal separator.
I further inspected the number format of SqlRecordChangedEventArgs and NumberDecimalDigits and NumberDecimalSeparator are correctly set.
So the only option for me was to refetch the record with EF without using SqlTableDependency. The result is as it is expected and the decimal value is correctly formatted.
Did anybody run into the same issue ?