Working in a BIML file, I've got 2 DataTables
that I am populating via an ExternalDataAccess.GetDataTable
call with a SQL query. I am looping over one inside of the other and am trying to 'tie' the 2 together by filtering the inner one on a value from the outer one.
I've gotten around this by coding the following:
foreach (DataRow t in Target.Rows) {
foreach (DataRow c in Columns.Rows) {
if (c["Object"].ToString() == t["ReferenceObject"].ToString()) {
//...
}
}
}
However, I would think there is a way to filter the inner foreach
loop. I may have 1000's of records in the inner DataSet
This is where my lack of experience is shining bright.
foreach (DataRow t in Target.Rows) {
foreach (DataRow c in Columns.Rows.Where(z => z["Object"].ToString() == t["ReferenceObject"].ToString())) {
//...
}
}
I get an error: 'System.Data.DataRowCollection'
does not contain a definition for 'Where' and no extension*... I know this isn't valid, but that's essentially what I'm trying to do. Is there a way to filter an inner foreach
loop based on a value from the outer foreach
loop?