Linq 構造複雜Json 多表group by

一個主表A(a1,a2),子表B(a1,b1,b2) ,想獲得的結果是 [{a1,a2,Info [{b1,b2},{b1,b2},...}]]List

var list=select

from a in Ajoin

join b in B on a.a1=b.a1new

group b by a into g

select new {

g.key.a1,

g.key.a2,

Info=g.select (c=>new {c.b1,c.b2}).ToList()

}.tolist()

相關文章
相關標籤/搜索