Ejemplo n.º 1
0
 public IEnumerable <T> ExecuteAndReadAll <T>(MapperWithIndex <T> mapper)
 {
     if (mapper == null)
     {
         throw new ArgumentNullException("mapper");
     }
     return(Execute(cmd => {
         using (var reader = cmd.ExecuteReader()) {
             return reader.ReadAll(mapper);
         }
     }));
 }
Ejemplo n.º 2
0
        public static IEnumerable <T> ReadAll <T>(this IDataReader reader, MapperWithIndex <T> mapper)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (mapper == null)
            {
                throw new ArgumentNullException("mapper");
            }
            var set = new List <T>();
            var i   = 0;

            while (reader.Read())
            {
                set.Add(mapper(reader, i));
                i++;
            }
            return(set.AsReadOnly());
        }