Using Dapper to save data that is decimal which is meant to go into an AlwaysEncrypted money field is resulting in this error:
Operand type clash: decimal(5,1) encrypted with (...) is incompatible with money encrypted with (...)
How do you explicitly tell Dapper to use money as the type as C# Decimal <-> Money is the preferred mapping?
decimal income = 4500m;
using (var connection = new ReliableSqlConnection(connectionString)) {
try {
connection.Open();
connection.Query<int>(
@"INSERT INTO [tablename]
([MonthlyAfterTaxIncome])
VALUES
(@MonthlyAfterTaxIncome);
SELECT CAST(SCOPE_IDENTITY() as int)",
new {
MonthlyAfterTaxIncome = income
})
.FirstOrDefault();
} finally {
connection.Close();
}
}
Column Details:
[MonthlyAfterTaxIncome] [money] ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = [KeyName], ENCRYPTION_TYPE = Deterministic, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256') NOT NULL,)