它加载类别,但始终使用 null 父级。我想获取具有给定 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;
}