CsvDataReader
. Yesterday evening, you started bending towards allowing DbDataReader
. Now it looks like you are willing to go even one more step up the inheritance tree and go up to IDataReader
.IEnumerable
you could potentially use Cast<T>()
and OrderBy<T>()
. But if you are willing to use Cast<T>()
, you might as well have just used the automatic class mapping that the Sylvan CsvDataReader provides.IEnumerable<Person> persons = CsvDataReader("persons.csv).Cast<Person>().OrderBy(p => p.Age);
IEnumerable<Person> persons = CsvDataReader("persons.csv).GetRecords<Person>().OrderBy(p => p.Age);
Probably user error, given that Mark's tested it to be the fastest already - GitHub - MarkPflug/Benchmarks: Benchmarks for various .NET libraries.I wish the parser was faster
using System;
using Sylvan.Data;
using Sylvan.Data.Csv;
using System.Collections.Generic;
using System.Linq;
using var csvReader = CsvDataReader.Create("data.csv");
IEnumerable<Planet> planets = csvReader.GetRecords<Planet>();
IEnumerable<Planet> sortedPlanets = planets.OrderBy(r => r.Size);
foreach(var planet in sortedPlanets)
Console.WriteLine($"Name: {planet.Name}, Size: {planet.Size}");
class Planet
{
public string Name { get; set; }
public int Size { get; set; }
}
DbDataReader
or IDataReader
.OrderBy()
.