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("插入成功");
        }

 

上一篇:函数编程09--自定义日志函数


下一篇:SpringBoot总结