I am left joining expected records to a returned set and attempting to determine if the expected column was updated correctly. The Column to be updated is determined by a string in the expected row.
Problem: I have a compile error I don't understand.
Cannot resolve symbol dbRow
(where bold/ bracketed by ** in QtyUpdated field).
var x = from addRow in expected.AsEnumerable()
join dbRow in dtDB.AsEnumerable()
on
new { key1= addRow[0], key2=addRow[1] ,key3=addRow[3] }
equals
new { key1=dbRow["TransactionID"],
key2=dbRow["TransactionItemID"],
key3=dbRow["DeliverDate"]
}
into result
from r in result.DefaultIfEmpty()
select new {TID = addRow[0], ItemID = addRow[1], DeliveryDate= addRow[3],
QtyUpdated= (
addRow[6].ToString() == "Estimated" ? **dbRow**["EstimatedQuantity"] == (decimal)addRow[5] :
addRow[6].ToString() == "Scheduled" ? **dbRow**["ScheduledQuantity"]==(decimal)addRow[5] :
addRow[6].ToString() == "Actual" ? **dbRow**["ActualQuantity"]== (decimal)addRow[5] : false)
};
I know this seems wonky, its a tool for Q/A to test that the Add function in our API actually worked.
Yes, dbRow
is only in scope within the equals
part of the join. However, you're not using your r
range variable - which contains the matched rows for the current addRow
... or null
.
Just change each dbRow
in the select
to r
. But then work out what you want to happen when there aren't any matched rows, so r
is null.
See more on this question at Stackoverflow