0、数据表结构,主要属性有:Id、parentId(父节Id)、Text、Url……等等。

asp.net mvc+EF 递归生成树结构返回json

1、新建一个树结构MenuModels

 1    public class MenuModels
 2     {
 3         private int _id;
 4         private string _text;
 5         private int? _parentid;
 6         private string _icon;
 7         private string _url;
 8         private object _menus;
 9         private Dictionary<string, string> _attributes = new Dictionary<string, string>();
10 
11         public int id
12         {
13             get { return _id; }
14             set { _id = value; }
15         }
16         public int? parentid
17         {
18             get { return _parentid; }
19             set { _parentid = value; }
20         }
21         public string text
22         {
23             get { return _text; }
24             set { _text = value; }
25         }
26         public string icon
27         {
28             get { return _icon; }
29             set { _icon = value; }
30         }
31         public string url
32         {
33             get { return _url; }
34             set { _url = value; }
35         }
36         public Dictionary<string, string> attributes
37         {
38             get { return _attributes; }
39             set { _attributes = value; }
40         }
41         public object menus
42         {
43             get { return _menus; }
44             set { _menus = value; }
45         }
46     }
View Code

相关文章:

  • 2021-11-27
  • 2022-02-26
  • 2021-11-05
  • 2022-12-23
  • 2022-02-09
  • 2021-12-03
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2022-01-16
  • 2021-12-16
  • 2022-12-23
  • 2021-07-25
  • 2021-09-03
  • 2022-12-23
相关资源
相似解决方案