I am trying to load my custom object with Data coming from Data Reader..How can I accomplish that
I can change the datareader to DATATable if it is better to use it
Reader Data
ID Description Type
1 Test1 1
2 Test2 2
3 Test3 1
4 Test4 3
5 Test5 3
my final Object should look something like this
type: 1
id:1
desc:Test1
id:3
desc:Test3
type: 2
id:2
desc:Test2
type: 3
id:4
desc:Test4
id:5
desc:Test5
Interface
public class Val
{
public string type { get; set; }
public List<valItems> valItems{ get; set; }
}
public class valItems
{
public string id { get; set; }
public string desc { get; set; }
}
function ( I am stuck here) it needs to b grouped by type see above final result)
ReadData()
{
//some code
if (reader.HasRows)
{
while(reader.Read())
{
dropdown.Add(new Dropdown
{
Type = Convert.ToString(reader["type"]),
valItems=
}),
});
}
}
}