Example #1
0
        public override IEnumerable <Dictionary <string, object> > ExecuteReader(string sql, SqlParameterCollection parameters, IDbTransaction transaction)
        {
            var queryCommand = CreateCommand(sql, parameters.ToDictionary());

            DbDataReader reader = null;

            reader = queryCommand.ExecuteReader();

            if (reader == null)
            {
                yield return(new Dictionary <string, object>());
            }
            else
            {
                var names = Enumerable.Range(0, reader.FieldCount).Select(reader.GetName).ToList();

                foreach (IDataRecord record in reader)
                {
                    var expando = new Dictionary <string, object>();

                    foreach (var name in names)
                    {
                        expando[name] = record[name];
                    }

                    yield return(expando);
                }
            }
        }