Can I use Linq to project a new typed datarow?
Posted
by itchi
on Stack Overflow
See other posts from Stack Overflow
or by itchi
Published on 2010-03-24T04:13:08Z
Indexed on
2010/03/24
4:23 UTC
Read the original article
Hit count: 198
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?
© Stack Overflow or respective owner