亚音速3和邻接模型 [英] Subsonic 3 and The Adjacency Model

查看:82
本文介绍了亚音速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.

这篇关于亚音速3和邻接模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆