我有一个清单:
var list = new List<Test>{
new Test = {
ID = 1,
Name = "Test 1",
RefId = 1
RefName = "Test RefName 1"
},
new Test = {
ID = 2,
Name = "Test 2",
RefId = 1
RefName = "Test RefName 1"
},
new Test = {
ID = 3,
Name = "Test 3",
RefId = 2
RefName = "Test RefName 2"
},
new Test = {
ID = 4,
Name = "Test 4",
RefId = 2
RefName = "Test RefName 2"
}
};
我想将顶部列表转换为新列表:
var list = new List<TestNew>{
new TestNew = {
RefId = 1,
RefName = "Test RefName 1",
ListGroup = new List<Group>{
new Group{
ID = 1,
Name = "Test 1"
},
new Group{
ID = 2,
Name = "Test 2"
},
}
},
new TestNew = {
RefId = 2,
RefName = "Test RefName 2",
ListGroup = new List<Group>{
new Group{
ID = 3,
Name = "Test 3"
},
new Group{
ID = 4,
Name = "Test 4"
},
}
}
};