Krishna Ramisetty

Krishna Ramisetty

  • 2.1k
  • 18
  • 1.1k

How to convert datatable to list object using c# linq

Jul 15 2021 1:18 PM

Hello Everyong, i have below datatable and below models. i need to fill each CenterList with respectives CenterInfo list usig c# linq. can someone pls help me how to do this

CenterID CenterName CenterLocation SupervisorID
2183 ABC AAA 54
2184 XHD BBB 48
2191 DHDF CCC 46
4145 DKD DDD 54
4145 DID EEE 54
4145 DKFD FFF 54
4170 DIDFKS GGG 54
4170 DIFGD HHH 54
4171 EFVF III 54
4171 AKDF JJJ 54
4172 GDHK KKK 54
4172 DIFGD LLL 54

    public class CenterList
    {        
        public List<CenterInfo> centers;   
        public int CenterID { get; set; }        
        public int SupervisorID { get; set; }
    }

public class CenterInfo
    {
        public string CenterName;      
        public string CenterLocation;
    }


Thanks
Krish


Answers (1)