I am fairly new to .Net and c# and I have come across a situation where I have to convert a flat list of objects into a nested list of objects. I am stuck and can't move any further.
I have this
[
{
id: 1,
name: "abc",
date: "8/8/20"
},
{
id: 2,
name: "xyz",
date: "9/8/20"
},
{
id: 1,
name: "def",
date: "9/8/20"
}
]
and I need to convert it into this
[
{
id: 1,
nameList: [
{
name: "abc",
date: "8/8/20"
},
{
name: "def",
date: "9/8/20"
}
]
},
{
id: 2,
nameList: [
{
name: "abc",
date: "8/8/20"
}
]
}
]
Can someone please help me out?