1
以下代碼嘗試檢索作爲斷開連接圖的導航屬性的對象。測試以查看導航屬性是否可以檢索值
如果屬性未加載發生錯誤時
的ObjectContext的實例已設置,並且不能再用於需要連接
操作 是否有辦法我可以測試該屬性是否加載?
navProps = GetNavigationProperties(originalEntity);
foreach (PropertyInfo navProp in navProps)
{
object obj = navProp.GetValue(item); // fails if the property type is an unloaded collection
// more code
}