示例#1
0
        private static void Dapper()
        {
            var sw       = Stopwatch.StartNew();
            var entities = PrepareEntities();

            sw.Stop();
            Console.WriteLine($"Preparing entities finished in {sw.ElapsedMilliseconds}ms");

            DapperPlusManager.Entity <TestEntity>()
            .Table("testentity")
            .Identity(x => x.Column1);

            using (var tx = new TransactionScope())
            {
                using (var con = new NpgsqlConnection("Host=192.168.1.90;Port=5432;Database=postgres;Username=postgres;Password=mysecretpassword"))
                {
                    con.Open();

                    sw = Stopwatch.StartNew();
                    con.BulkInsert <TestEntity>(entities);
                    sw.Stop();
                    Console.WriteLine($"Inserting entities took {sw.Elapsed.TotalSeconds}s");
                }

                tx.Complete();
            }
        }