Ejemplo n.º 1
0
        public static SqlBuilderResultRow FromReader(DbDataReader reader)
        {
            var result        = new SqlBuilderResultRow();
            var columnSchemas = reader.GetColumnSchema();

            for (int i = 0; i < reader.FieldCount; i++)
            {
                result.Add(columnSchemas[i].BaseTableName ?? "", reader.GetName(i), reader.GetValue(i));
            }
            return(result);
        }
Ejemplo n.º 2
0
        public IReadOnlyList <SqlBuilderResultRow> ToResults(string query, IDictionary <string, object?> parameters)
        {
            var cmd = BuildCommand(query, parameters);

            var results = new List <SqlBuilderResultRow>();

            using (var reader = cmd.ExecuteReader()) {
                while (reader.Read())
                {
                    results.Add(SqlBuilderResultRow.FromReader(reader));
                }
            }
            return(results.AsReadOnly());
        }
Ejemplo n.º 3
0
        public async Task <IReadOnlyList <SqlBuilderResultRow> > ToResultsAsync(
            string query, IDictionary <string, object?> parameters)
        {
            using (_connection) {
                await _connection.OpenAsync();

                var cmd = BuildCommand(query, parameters);

                var results = new List <SqlBuilderResultRow>();
                using (var reader = await cmd.ExecuteReaderAsync()) {
                    while (await reader.ReadAsync())
                    {
                        results.Add(SqlBuilderResultRow.FromReader(reader));
                    }
                }
                return(results.AsReadOnly());
            }
        }