FileHelpers icon indicating copy to clipboard operation
FileHelpers copied to clipboard

Read header in file and then match the model with headers and their order, instead of statically defining field order in model

Open sandip4git opened this issue 2 years ago • 0 comments

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.

sandip4git avatar Jan 20 '24 15:01 sandip4git