Beispiel #1
0
        public async Task InsertAsync()
        {
            var batchInsertNum = 1000000;
            var batchTable     = new DbTable("t_test");

            batchTable.AddColumn(new DbColumn
            {
                AutoIncrement = true,
                DataType      = typeof(long),
                Name          = "id"
            });
            batchTable.AddColumn("name");
            batchTable.AddColumn("no");
            for (var i = 0; i < batchInsertNum; i++)
            {
                var row = batchTable.AddRow();
                row["name"] = "SmartSql-" + Guid.NewGuid().ToString("N");
                row["no"]   = i;
            }
            using (BatchInsert batchInsert = new BatchInsert(_sqlMapper))
            {
                batchInsert.Table = batchTable;
                await batchInsert.InsertAsync();
            }
        }
Beispiel #2
0
        public async Task InsertAsync()
        {
            var batchInsertNum = 1000000;
            var batchTable     = new DbTable("t_test");

            batchTable.AddColumn("Name");
            batchTable.AddColumn("No");
            for (var i = 0; i < batchInsertNum; i++)
            {
                var row = batchTable.AddRow();
                row["Name"] = "SmartSql-" + Guid.NewGuid().ToString("N");
                row["No"]   = i;
            }
            using (BatchInsert batchInsert = new BatchInsert(_sqlMapper))
            {
                batchInsert.Table = batchTable;
                batchInsert.AddColumnMapping(new ColumnMapping
                {
                    Column  = "Name",
                    Mapping = "name"
                });
                batchInsert.AddColumnMapping(new ColumnMapping
                {
                    Column  = "No",
                    Mapping = "no"
                });
                await batchInsert.InsertAsync();
            }
        }