請諮詢之前檢查空值。 這是代碼的Linq:訪問屬性有關錯誤
void Main()
{
var a = from id in TechnicalProducts
where id.Id == "ID-4591"
select new {
Country = id.Computers.Select (x => new {x.Location.ParentLocation.ParentLocation.ParentLocation.ParentLocation.Code}),
};
Console.WriteLine(a);
}
錯誤:由導航屬性「代碼」返回一個項爲無效,不能初始化。你應該檢查空值,訪問此屬性之前
但如果將我加入這行? – Swapnil 2012-07-20 17:22:03
請檢查我的帖子。 – 2012-07-21 04:37:39