fix: Use IDictionary.GetEnumerator explicitly to iterate keyvals
We really need to replace these old non-generic collections with generic ones. BlueRow's IDictionaryEnumerator implementation iterates over values when passed to a foreach loop, not key value pairs.
This commit is contained in:
1 parent
0746b27a40
commit
10bb90c731
2 files changed
+12
-3
No files matched your search
@@ -88,9 +88,16 @@ namespace BCG
|
||||
public BlueRow(IBlueTableSchema schema, IDictionary row)
|
||||
{
|
||||
myInit(schema);
|
||||
foreach (DictionaryEntry de in row)
|
||||
if (mySchema[de.Key as string] != null)
|
||||
// Use GetEnumerator instead of a foreach loop because the latter calls
|
||||
// '((IEnumerator)row).GetEnumerator()', which iterates over values
|
||||
// instead of key value pairs.
|
||||
var en = row.GetEnumerator();
|
||||
while (en.MoveNext()) {
|
||||
var de = en.Entry;
|
||||
if (mySchema[de.Key as string] is not null) {
|
||||
myValues[mySchema[de.Key as string].colNo] = de.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user