I wanted to know how to write this in linq below. Basically for every row by id in the testTable find the related fk Id in the Log table and insert the row in the LogTable , then set then assigned the Log table to grid.DataSource
foreach (databaseDataSet.testRow testRow in testTable.Rows)
{
foreach (databaseDataSet.logRow logRow in LogTable.Rows)
{
Import record into LogTable
}
}
grid.DataSource = LogTable;
Loading

VulpesRank #55 · 29.2K reputationPosted Feb 13, 2012, 5:54 AM EST
David SmithRank #999 · 2K reputationPosted Feb 13, 2012, 2:06 PM EST
foreach (databaseDataSet.testRow testRow in testTable.Rows)
{
foreach (databaseDataSet.logRow logRow in LogTable.Rows)
{
Import record into LogTable or find related records by id
}
}
grid.DataSource = LogTable;
VulpesRank #55 · 29.2K reputationPosted Feb 14, 2012, 11:26 AM EST
David SmithRank #999 · 2K reputationPosted Feb 14, 2012, 1:50 PM EST
var testTable = from t in this.testTableAdapter1.GetData()
where t.colorSerialNumber.StartsWith("s")
select t.ToList();
this.ultraGrid1.DataSource = testTable;
var LogTableData = (from c in this.logTableAdapter.GetData()
join td in testTable on c.fk_TestTableId equals td.TestTableId
select c).ToList();
this.ultraGrid2.DataSource = LogTableData ;
Your way and my way works, But I can replace the var with IEnumerable
David SmithRank #999 · 2K reputationPosted Feb 14, 2012, 1:56 PM EST
right values with out iterating throught all of the records if i can remember. I have quite got it yet, im working on it below.
//if (dataRow != null)
//{
// databaseDataSet.testRow row = dataRow as databaseDataSet.testRow;
// if (row != null)
// {
// databaseDataSetTableAdapters.pdataTableAdapter ad = new databaseDataSetTableAdapters.pdataTableAdapter();
// ad.Fill(this.databaseDataSet.logTable);
// databaseDataSet.pdataRow[] logDataRowsArray = row.GetpdataRows();
// logDataRowsArray for some reason is returning null, but when I look in row, it actually has a row, so im not for sure whats going on at the moment
// }
//}