sql server - Extracting a subset of DataTable columns in C# and then sending them to browser client as a JSON string -
here's scenario: c# middle tier webservice has data sent sql server in system.data.datatable object. there dozens of columns in datatable's columns collection. browser client needs see 6 of them. stored proc on server general purpose, not designed specific task. assume have use it, rather writing new sp. is there simple way, perhaps using generics, extract desired subset of columns datatable list or collection, , convert resulting list or collection json using json.net? is possible create skeletal c# class definition foo relevant field names (and datatypes) , match on field names "automagically" , thereby generate list<foo> datatable's rows collection? ideally, during json conversion, sql server datetime values (e.g. 2014-06-24t18:45:00 ) converted value make easy instantiate javascript date in client without having string manipulation of date representation. full working console app code pasted below. 2 main methods need follows. f