正向遞迴和反向遞迴

2021-08-13 20:56:51 字數 925 閱讀 1174

//反向遞迴   找到最低層的選單一步步往上查    (先逆向遞迴然後再反向遞迴)

var list = newlist.where((x, i) => newlist.findindex(z => z.id == x.id) == i);//陣列去重

///************************

string actionsql = string.format("select a.*,r.roleid from yf_action a left join yf_role_action r on  a.id=r.actionid and r.roleid=", input.roleid);

var actionlist = dbcontext.database.sqlquery(actionsql).tolist();

var newlist = new list();

foreach (yf_menu menu in list)

if (input.outdatatype == 1)//樹形

else if (input.outdatatype == 2)//資料字典

else//陣列

//遞迴找上級方法

//遞迴找上級

private listgetparentmenulist(yf_menu menunode, listalllist)

return newlist;

}**********正向遞迴

//生成樹

private getmenulistoutput initmenutree(getmenulistoutput menu, listlist)

return menu;

}

ORM正向和反向查詢

表結構 from django.db import models create your models here.class publisher models.model id models.autofield primary key true name models.charfield max l...

ORM正向和反向查詢

表結構 from django.db import models class publisher models.model id models.autofield primary key true name models.charfield max length 32 class book mode...

ORM正向和反向查詢

表結構 from django.db import models create your models here.class publisher models.model id models.autofield primary key true name models.charfield max l...