Datatable-使用linq,我想用count更新一行
本文关键字:更新 一行 count linq 使用 Datatable- | 更新日期: 2023-09-27 18:25:41
我有一个C#数据表,其中包含:
Id ParentId Name
======== =========== =====
1 A
2 1 b
3 1 c
4 2 d
6 5 e
我想添加一列或仅添加一个结果,以标识任何没有Id
的ParentId
。基本上在上表中,我想找到Id=6
,因为ParentId
5是无效的。
我想在parentId
未列为Id
的任何地方进行识别
我原以为林克可以做到这一点。
这将返回ParentId
未作为Id
出现在任何行中的所有行
rows.Where(r1 => !rows.Any(r2 => r1["ParentId"] == r2["Id"]))