我正在尝试使用一个不错的近对象设置器,但有空问题。
我现在的代码:
var Result = new RefundReplyObject
{
AuthorisationNumber = reply.refundResponse.transactionDetails.authorisationNumber,
ChargeValue = reply.refundResponse.transactionDetails.totalAmount.amount,
Message = reply.refundResponse.transactionDetails.message,
ReconciliationReference = reply.refundResponse.transactionDetails.reconciliationReference,
SettlementDate = reply.refundResponse.transactionDetails.settlementDate,
Status = TransactionStatusToLocalModel(reply.refundResponse.transactionDetails.status),
TransactionReference = reply.refundResponse.transactionDetails.transactionReference
};
但是...“totalAmount”可能为空。所以,我得到错误。
有没有一种巧妙的方法来处理这个问题,如果“totalAmount”为空,那么将chargevalue设置为零?