I have a little program that fetches data from a web service. The program takes the JSON response, maps it to POCOs and writes the objects to a CSV file (automapping). It works perfectly when I ask for "all" the data in the dataset, however, if I query the resource (via OData) like this: "$select EmpNo, FirstName, LastName", the CSV writer will still write all of the columns to the CSV header, e.g. "EmpNo, FirstName, LastName, Street, Address, City, Age" etc. and just insert 0 (if int), false(if boolean) or "" (if string) to the columns that have no data.
The web service correctly returns only the specified columns, so that's not the issue. I use CsvHelper for the object mapping and CSV-writing. (But I'm open to using anything that can solve my problem)
I'd like to only write "EmpNo, FirstName, LastName" and the columns' data to the CSV-file, if that's what I ask for in the OData query.
Any good ideas for solving this?