其他分享
首页 > 其他分享> > ShardingCore批量插入

ShardingCore批量插入

作者:互联网

 public async Task Test()
        {
            List<Industrial> list = new List<Industrial>();

            for (int i = 0; i < 10000; i++)
            {
                list.Add(new Industrial()
                {
                    PrimaryKey = Guid.NewGuid(),
                    YearStr = "2021",
                    UpdateTime = DateTime.Now.AddYears(-1)
                }); ;
            }
            _or public async Task Test()
        {
            List<Industrial> list = new List<Industrial>();

            for (int i = 0; i < 10000; i++)
            {
                list.Add(new Industrial()
                {
                    PrimaryKey = Guid.NewGuid(),
                    YearStr = "2021",
                    UpdateTime = DateTime.Now.AddYears(-1)
                }); ;
            }
            _orclContext.Database.EnsureCreated();
            _logger.LogInformation($"Oracle连接{_orclContext.Database.CanConnect()}");
            _logger.LogInformation($"生成对象完成{list.Count}");
            var bulkShardingEnumerable = _orclContext.BulkShardingTableEnumerable(list);

            foreach (var dataSourceMap in bulkShardingEnumerable)
            {
                dataSourceMap.Key.BulkInsert(dataSourceMap.Value.ToList());
            }
            _logger.LogInformation("插入成功");
        }clContext.Database.EnsureCreated();
            _logger.LogInformation($"Oracle连接{_orclContext.Database.CanConnect()}");
            _logger.LogInformation($"生成对象完成{list.Count}");
            var bulkShardingEnumerable = _orclContext.BulkShardingTableEnumerable(list);

            foreach (var dataSourceMap in bulkShardingEnumerable)
            {
                dataSourceMap.Key.BulkInsert(dataSourceMap.Value.ToList());
            }
            _logger.LogInformation("插入成功");
        }

 

标签:orclContext,批量,bulkShardingEnumerable,list,dataSourceMap,插入,LogInformation,Shard
来源: https://www.cnblogs.com/bihuijia/p/15502368.html