FlexLabs.Upsert icon indicating copy to clipboard operation
FlexLabs.Upsert copied to clipboard

Exception due to null constant in expression + Fix.

Open timaiv opened this issue 1 year ago • 3 comments

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;)

timaiv avatar Sep 21 '22 13:09 timaiv