亚音速3和邻接模型

问题描述:

如果表应用了邻接模型(ID,ParentID),那么如何在Subsonic 3中返回层次结构?

If a table has the adjacency model applied (ID,ParentID) how can the hierarchy be returned in Subsonic 3?

所有类都是局部的,因此请为您的类创建一个新的局部(假设它是Category),并创建子集合(将其称为SubCategories).然后,当您将对象加载到内存中时,您可以加载子集合:

All classes are partials, so create a new partial for your class (let's say it' Category) and create child collection (call it SubCategories). Then when you load your object into memory you can load the subcollection:

var allCategories=Categories.All().ToList();
allCategories.ForEach(x=>x.SubCategories=allCategories.Where(y=>y.CategoryID==x.ParentID));

那是徒劳的,但这就是想法.

That's freehanded, but that's the idea.