-1
我有数据列表。例如。从类别到子类别的Linq分组
| Id | Name | GroupId | GroupName |
|----|------|---------|-----------|
| 1 | nm1 | 1 | Group1 |
| 2 | nm2 | 1 | Group1 |
| 3 | nm3 | 1 | Group1 |
| 4 | nm4 | 2 | Group2 |
| 5 | nm5 | 2 | Group2 |
{ id = 1, Name = "nm1", GroupId = 1, GroupName = "Group1" }
{ id = 2, Name = "nm2", GroupId = 1, GroupName = "Group1" }
我想要结果列表只有Id,Name。来自GroupId的Id变为-1。一个Id值为-1的空值也是需要的。 (空白)
| Id | Name |
|----|-----------|
| -1 | Group1 |
| 1 | nm1 |
| 2 | nm2 |
| 3 | nm3 |
| -1 | blank |
| -1 | Group2 |
| 4 | nm4 |
| 5 | nm5 |
是否有可能?
为什么第一组包括5? – Rob
@Rob抱歉,我的错误。我纠正了谢谢。 – user696383