FlexLabs.Upsert
FlexLabs.Upsert copied to clipboard
Exception due to null constant in expression + Fix.
Version
6.0.1
Exception message:
The parameterized query '(@p0 bigint,@p1 datetime2(7),@p2 int,@p3 int,@p4 varchar(100),@p' expects the parameter '@p5', which was not supplied.
How to reproduce:
.WhenMatched((dbTx, upTx) => new TransactionInfo()
{
SenderId = dbTx.SenderId == null ? upTx.SenderId : dbTx.SenderId
})
Fix:
In PrepareDbCommandArgument
change dbParameter.Value = constantValue.Value
to dbParameter.Value = constantValue.Value ?? DBNull.Value
Microsoft does same in CreateParameter
(parameter.Value = value ?? DBNull.Value;
)