Example #1
0
        public void TestSqlBulkInsert()
        {
            int rows = 11111;

            string           channel = $"bitest_{new Random().Next(100000, 999999).ToString()}";
            List <testClass> list    = new List <testClass>();

            for (int i = 0; i < rows; i++)
            {
                list.Add(Helper.GetNew(channel, i));
            }
            var res = dbc.BulkInsertSql(list);

            Assert.AreEqual(rows, res);

            //cleanup
            var delete = dbc.Delete <testClass>(new { channel = channel });

            Assert.AreEqual(rows, delete);
        }
Example #2
0
        public static int BulkInsertSql <T>(this IDbConnection con, IEnumerable <T> dataList, IEnumerable <PropertyInfo> excludedColumns, int linesPerBatch = 1000, int timeout = 0, DMLOptions options = null)
        {
            Func <PropertyInfo, Boolean> filter = (PropertyInfo pi) => { return(!excludedColumns.Contains(pi)); };

            return(con.BulkInsertSql(dataList, excludedColumns.HasAny() ? filter : null, linesPerBatch, timeout, options));
        }