public static List <RecordTable> ReadAll(this DbDataReader reader)
        {
            Argument.IsNotNull(() => reader);

            var results = new List <RecordTable>();

            while (true)
            {
                if (!reader.HasRows)
                {
                    break;
                }

                var result = new RecordTable
                {
                    Headers = reader.GetHeaders()
                };

                while (reader.Read())
                {
                    var record = new Record();
                    for (var i = 0; i < result.Headers.Length; i++)
                    {
                        var name  = result.Headers[i];
                        var value = reader.GetValue(i);

                        record[name] = value;
                    }

                    result.Add(record);
                }

                results.Add(result);

                if (!reader.NextResult())
                {
                    break;
                }
            }

            return(results);
        }
Example #2
0
        public static List <RecordTable> ReadAll(this IReader reader)
        {
            Argument.IsNotNull(() => reader);

            var results = new List <RecordTable>();

            while (true)
            {
                var result = new RecordTable
                {
                    Headers = reader.FieldHeaders
                };

                while (reader.Read())
                {
                    var record = new Record();
                    for (var i = 0; i < result.Headers.Length; i++)
                    {
                        var name  = result.Headers[i];
                        var value = reader[i];

                        record[name] = value;
                    }

                    result.Add(record);
                }

                results.Add(result);

                if (!reader.NextResultAsync().GetAwaiter().GetResult())
                {
                    break;
                }
            }

            return(results);
        }
        public static bool HasHeaders(this RecordTable table)
        {
            Argument.IsNotNull(() => table);

            return(table.Headers?.Any() ?? false);
        }