Exemplo n.º 1
0
        public async Task <long> BulkInsert <T>(string tableName, List <T> bulk)
        {
            using var bulkCopyInterface = new ClickHouseBulkCopy(_clickHouseConnection)
                  {
                      DestinationTableName = tableName,
                      BatchSize            = bulk.Count
                  };
            var(items, columns) = _commandFormatter.BulkInsert(bulk);
            await bulkCopyInterface.WriteToServerAsync(items, columns);

            return(bulkCopyInterface.RowsWritten);
        }
Exemplo n.º 2
0
        public void BulkInsert <T>(string tableName, IEnumerable <string> columns, IEnumerable <T> bulk)
        {
            var query = _commandFormatter.BulkInsert(tableName, columns);

            Execute(cmd =>
            {
                cmd.Parameters.Add(new ClickHouseParameter
                {
                    ParameterName = "bulk",
                    Value         = bulk
                });
                cmd.ExecuteNonQuery();
            }, query);
        }