Can I use Linq to project a new typed datarow?
- by itchi
I currently have a csv file that I'm parsing with an example from here:
http://alexreg.wordpress.com/2009/05/03/strongly-typed-csv-reader-in-c/
I then want to loop the records and insert them using a typed dataset xsd to an Oracle database.
It's not that difficult, something like:
foreach (var csvItem in csvfile)
{
DataSet.MYTABLEDataTable DT = new DataSet.MYTABLEDataTable();
DataSet.MYTABLERow row = DT.NewMYTABLERow();
row.FIELD1 = csvItem.FIELD1;
row.FIELD2 = csvItem.FIELD2;
}
I was wondering how I would do something with LINQ projection:
var test = from csvItem in csvfile
select new MYTABLERow {
FIELD1 = csvItem.FIELD1,
FIELD2 = csvItem.FIELD2
}
But I don't think I can create datarows like this without the use of a rowbuilder, or maybe a better constructor for the datarow?