2
IndicationBase indication = new IndicationBase(Chatham.Web.UI.Extranet.SessionManager.PhysicalUser);
// check for permissions
LightDataObjectList<TransactionPermission> perms = indication.Model.Trx.TransactionPermissionCollection;
所以有時indication
將有一個Model.Trx.TransationPermissionCollection
,很多時候它不會。在嘗試訪問它之前如何檢查它是否發生,以免出現錯誤。c#使用前檢查屬性是否存在
有使用`dynamic`和/或表達式樹的工作方式圍繞這個問題......但是對於通常需要這種情況的少數情況來說,它們不夠優雅而且過於複雜。 – LBushkin 2011-01-27 22:22:53