Read header in file and then match the model with headers and their order, instead of statically defining field order in model
Example 1, if below file is give as a input
"RECHNUNG";"DATUM";"KUNDENNR";"DEBITORKONTO" "12345";"04.08.2020 00:00:00";"12345";""; "12345";"04.08.2020 00:00:00";"12345";"" "12345";"04.08.2020 00:00:00";"12345";""
Then we should have attribute [MatchHeadersToModel] on model class should result in field order in model as "RECHNUNG" : 1 "DATUM": 2 "KUNDENNR" : 3 "DEBITORKONTO" : 4
Example 2., if below file is give as a input
"DATUM";"RECHNUNG";"KUNDENNR";"DEBITORKONTO" "04.08.2020 00:00:00";"12345";"12345";""; "04.08.2020 00:00:00";"12345";"12345";"" "04.08.2020 00:00:00";"12345";"12345";""
Then we should have attribute [MatchHeadersToModel] on model class should result in field order in model as "DATUM": 1 "RECHNUNG" : 2 "KUNDENNR" : 3 "DEBITORKONTO" : 4
So, basically, we are reading header in file and then matching the model with headers and their order, instead of statically defining in file.