linq js groupBy

linq js groupBy 使用示例

var list=[
  {id:1,name:"lily",gender:0,o:{id:123}},
  {id:2,name:"lucy",gender:0,o:{id:456}},
  {id:3,name:"lilei",gender:1,o:{id:123}},
  {id:4,name:"hanmeimei",gender:0,o:{id:789}}                            
];

Enumerable.from(list).groupBy(x=>x.o.id).select(x=>({key:x.key(),source:x.getSource()})).toArray();

參考文章

https://github.com/mihaifm/linq/blob/master/sample/tutorial.js

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章