求lambda查询的写法,感谢各位大佬
问题描述:
想要查询1直接推荐的2、3、4用户推荐关系下所有的激活金额
查询结果的示例
2:9000
3: 1000
4:0
答
这个递归下即可
int getAmount(int id)
{
var users = table.Where(x => x.RecommendId == id);
if (users.Count() == 0) return 0;
return users.Select(x => getAmount(x.id)).Sum();
}