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
David SmithPosted Feb 14, 2012, 6:56 PM
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
// }
//}
David SmithPosted Feb 14, 2012, 6:50 PM
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
VulpesPosted Feb 14, 2012, 4:26 PM
David SmithPosted Feb 13, 2012, 7:06 PM
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;
VulpesPosted Feb 13, 2012, 10:54 AM