Help to understand EpiDataView vs DataTable

I have working code to export to CSV from an EpiDataView (thanks to @Chris_Conn and @josecgomez for helping on an earlier post)

I have an enhancement request from our supplier who we’re sending the CSV file to sort the CSV file by 2 columns. My question is, do I sort the EpiDataView, perform the export and then sort back to original order. Or, should I create a DataTable in C# code, populate it with the same data from the EpiDataView, sort the new table and then export from that before disposing of it?

Thanks

Probably the easiest way (note this sorts your view as well)


   dv.Sort = "MyColName desc";
   DataTable sortedDT = dv.ToTable();
   //do all of you data gathering on sortedDT

if you want to avoid sorting the base view:

DataView dataView = new DataView(baseDataView.dataView.Table);
dataView.Sort = " MyColOne DESC, MyCol2 DESC";
1 Like

Perfect, thanks Chris!