How do I convert a datatable into a POCO object in Asp.Net MVC?
How do I convert a datatable into a POCO object in Asp.Net MVC? Pass each DataRow into the class constructor (or use getters/setters) and translate each column into the corresponding property. Be careful with nullable columns to extract them properly. public class POCO { public int ID { get; set; } public string Name { get; set; } public DateTime? Modified { get; set; } ... public POCO() { } public POCO( DataRow row ) { this.ID = (int)row["id"]; this.Name = (string)row["name"]; if (!(row["modified"] is DBNull)) { this.Modified = (DateTime)row["modified"]; } ... } } A data table typically holds