Hello, ube100,
wrt question #2:
(afaik) you can cast null to any type you like. It is still null. That is, I believe the casting is unnecessary, but probably does no harm.
wrt question #1:
In general, whether a function can accept null as a value (and what it does with a null value) is up to the function. Sorry, but I don't know the details for the PrepareCommand function. However, I would guess that passing in a null for transaction would mean that the command would NOT be executed as part of a transaction.
Cheers,
Randy