So we have had a heated debate at work as to which DataAccess route to take: DataTable or DataReader.
DISCLAIMER I am on the DataReader side and the
SqlDataAdapter.Fill
calls SqlCommand.ExecuteReader with CommandBehavior.SequentialAccess
set. Maybe that's enough to make the difference.
As an aside, I see your IDbReader
implementation caches the ordinals of each field for performance reasons. An alternative to this approach is to use the DbEnumerator class.
DbEnumerator
caches a field name -> ordinal dictionary internally, so gives you much of the performance benefit of using ordinals with the simplicity of using field names:
foreach(IDataRecord record in new DbEnumerator(reader))
{
artifactList.Add(new ArtifactString() {
FormNumber = (int) record["FormNumber"],
FormOwner = (int) record["FormOwner"],
...
});
}
or even:
return new DbEnumerator(reader)
.Select(record => new ArtifactString() {
FormNumber = (int) record["FormNumber"],
FormOwner = (int) record["FormOwner"],
...
})
.ToList();