Beispiel #1
0
        public void DataEdit()
        {
            var dataList    = CommonHelper.GetTestListDto(5000);
            var dataListTwo = CommonHelper.GetTestListDtoTwo(5000);
            var table       = SqlBulkCopyHelper.ListToTable(dataList, "BulkTest");
            var tableTwo    = SqlBulkCopyHelper.ListToTable(dataListTwo, "BulkTestTwo");

            var tableUpdate    = SqlCoreHelper.ExecuteDataSetText("select top 5000 Id,FieldD from BulkTest order by FieldU asc", null).Tables[0];
            var tableTwoUpdate = SqlCoreHelper.ExecuteDataSetText("select top 5000 Id,FieldD from BulkTestTwo order by FieldU asc", null).Tables[0];

            foreach (DataRow item in tableUpdate.Rows)
            {
                item["FieldD"] = "555";
            }
            foreach (DataRow item in tableTwoUpdate.Rows)
            {
                item["FieldD"] = "666";
            }
            tableUpdate.TableName    = "BulkTest";
            tableTwoUpdate.TableName = "BulkTestTwo";
            Stopwatch sw = new Stopwatch();

            sw.Start();
            SqlBulkCopyHelper.BulkEditTables(new List <DataTable>()
            {
                table, tableTwo
            }, new List <DataTable>()
            {
                tableUpdate, tableTwoUpdate
            });
            sw.Stop();
            string bb = sw.Elapsed.TotalSeconds.ToString();

            Console.WriteLine(bb);
        }
Beispiel #2
0
        public void DataInsert()
        {
            var       dataList    = CommonHelper.GetTestListDto(5000);
            var       dataListTwo = CommonHelper.GetTestListDtoTwo(5000);
            var       table       = SqlBulkCopyHelper.ListToTable(dataList, "BulkTest");
            var       tableTwo    = SqlBulkCopyHelper.ListToTable(dataListTwo, "BulkTestTwo");
            Stopwatch sw          = new Stopwatch();

            sw.Start();
            SqlBulkCopyHelper.BulkInsertTables(new List <DataTable>()
            {
                table, tableTwo
            }).Wait();
            sw.Stop();
            string bb = sw.Elapsed.TotalSeconds.ToString();

            Console.WriteLine(bb);
        }