JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.65k stars 1.05k forks source link

[Feature] Deserialise into named tuple #2212

Open lonix1 opened 7 months ago

lonix1 commented 7 months ago

Is your feature request related to a problem? Please describe. When deserialising lots of CSVs, it's a bother to declare a throw-away type for each. Luckily the library supports anonymous types:

var anonymousTypeDefinition = new
{
  Id = default(int),
  Name = string.Empty
};
var records = csv.GetRecords(anonymousTypeDefinition);

But it would be even nicer to use a named tuple.

Describe the solution you'd like

var records = csv.GetRecords<(int Id, string Name)>();