Subsonic 3 分层收藏创建?
我有一个表,里面有层次结构。我正在使用 ActiveRecord。如何将其转换为分层集合,然后将其绑定到 WinForms 或 WPF 树视图?
谢谢。
ID Name ParentID
1 ALL 1
2 ARGENTINA 1
15 AUSTRALIA 1
16 NW 15
17 BLACKTOWN 16
18 CORLETTE 16
19 PRIMBEE 16
20 TWEED HEADS 16
21 QL 15
22 ASHMORE 21
23 ROBERTSON 21
24 TOOWOOMBA 21
25 TRINITY BEACH 21
26 UNITED STATES 1
27 AK 26
28 CA 26
29 NJ 26
30 NIKISKI 27
31 AMADOR CITY 28
32 MOSS BEACH 28
33 Essex 29
34 Newark 33
35 Ampere 33
36 Avondale 33
37 Beaufort 33
I have a single table with a hierarchy inside. I am using ActiveRecord. How can I convert this into a hierarchic collection that I can then bind to a WinForms or WPF treeview?
Thanks.
ID Name ParentID
1 ALL 1
2 ARGENTINA 1
15 AUSTRALIA 1
16 NW 15
17 BLACKTOWN 16
18 CORLETTE 16
19 PRIMBEE 16
20 TWEED HEADS 16
21 QL 15
22 ASHMORE 21
23 ROBERTSON 21
24 TOOWOOMBA 21
25 TRINITY BEACH 21
26 UNITED STATES 1
27 AK 26
28 CA 26
29 NJ 26
30 NIKISKI 27
31 AMADOR CITY 28
32 MOSS BEACH 28
33 Essex 29
34 Newark 33
35 Ampere 33
36 Avondale 33
37 Beaufort 33
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个分部类并添加属性 Children (或任何有意义的内容)。
然后,在某个方法中(在您的存储库、BLL 等)中,循环并加载:
Create a partial class and add the property Children (or whatever makes sense).
Then, in a method somewhere (in your repo, BLL, whatever), loop and load: