private static IEnumerable <T> ToEnumerable <T>(IDataReader dataReader, IDataRecordMapper mapper) { if (dataReader.FieldCount == 0) { yield break; } while (dataReader.Read()) { yield return(mapper.MapDataRecord <T>(dataReader)); } yield break; }
private IEnumerable <T> ToEnumerable <T>(IConnection connection, DbCommand command, DbDataReader dataReader) { using (connection) using (command) using (dataReader) { if (dataReader.FieldCount == 0) { yield break; } IDataRecordMapper <T> mapper = null; while (dataReader.Read()) { mapper ??= _dataRecordMapperFactory.CreateMapper <T>(); yield return(mapper.MapDataRecord(dataReader)); } yield break; } }