My objects often has nullable types properties that used as SQL commands parameters.
I initialize them next way:
public int? Amount
{
get
{
int i;
int? amount = null;
if (Int32.TryParse(Request["amount"], out i))
{
amount = i;
}
return amount;
}
}
command.Parameters.Add("@amount").Value = (object)this.Amount ?? DbNull.Value;
How can I rewrite such initialization code to make it shorter or faster?