/// <summary>
/// Create the data reader.
/// </summary>
/// <param name="layer">Data access layer that will give us the TextReader we need.</param>
/// <param name="mapping">ClassMapping for the type we're returning.</param>
/// <param name="criteria">Since there is no way to filter before we read the file,
/// the reader checks each row read to see if it matches the
/// criteria, if not, it is skipped.</param>
public CsvDataReader(CsvDaLayer layer, ClassMapping mapping, DaoCriteria criteria)
: base(layer, mapping, criteria, GetConfig(layer, mapping))
{
_reader = ((CsvDataReaderConfig) _config).Reader;
try
{
PreProcessSorts();
}
catch (Exception e)
{
// Close the reader on error, since if the constructor throws
// it isn't very reasonable to expect anyone else to call Close.
if (_reader != null)
{
layer.DoneWithReader(_reader);
}
throw new LoggingException("Unable to read from CSV file and process sorts.", e);
}
}