1
它加載類別但始終爲空父代。我想獲得給定ID的層次結構類別。父類別在實體框架延遲加載模式下始終爲空
public static Category GetCategory(System.Guid ID, ActionLinkInfo AInfo)
{
Category category = null;
using (TIKSN.STOZE.Data.StozeContext DContext = new Data.StozeContext())
{
var cats = from cat in DContext.Categories where cat.ID == ID select cat;
foreach (Data.Category Cat in cats)
{
category = new Category(Cat, Cat.Parent == null ? null : GetCategory(Cat.Parent.ID, AInfo), AInfo);
}
}
return category;
}
但這不是懶加載。這是急切的負載。 – TIKSN