Skip to content

Commit 5645820

Browse files
author
Christian Käser
committed
Do not rely on column order when deserializing CSV
1 parent 6fd81dc commit 5645820

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

FileContextCore/Serializer/CSVSerializer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public Dictionary<TKey, object[]> Deserialize<TKey>(string list, Dictionary<TKey
2828
CsvReader reader = new CsvReader(tr);
2929

3030
reader.Read();
31+
reader.ReadHeader();
3132

3233
while (reader.Read())
3334
{
@@ -36,7 +37,7 @@ public Dictionary<TKey, object[]> Deserialize<TKey>(string list, Dictionary<TKey
3637

3738
for (int i = 0; i < propertyKeys.Length; i++)
3839
{
39-
object val = reader.GetField(i + 1).Deserialize(typeList[i]);
40+
object val = reader.GetField(propertyKeys[i]).Deserialize(typeList[i]);
4041
value.Add(val);
4142
}
4243

0 commit comments

Comments
 (0)