private static void Initialize() { string address = ConfigurationManager.AppSettings["ExcelSource"]; DataTable tb = GetExcelTable(address); var tasks = DataConvert <Tasks> .ToList(tb); List <TaskDto> taskSqls = ConvertToSqlFields(tasks); StringBuilder sqls = new StringBuilder(); string dbName = ConfigurationManager.AppSettings["dbName"]; sqls.Append("Set IDENTITY_INSERT " + dbName + " on;"); sqls.AppendLine(); //bulk string sql = SqlBuilderHelper.BulkInsertSql(taskSqls, "AppTasks"); sqls.Append(sql); //single //taskSqls.ForEach(task => //{ // sqls.Append(SqlBuilderHelper.InsertSql(task, "AppTasks")); // sqls.AppendLine(); //}); CreateSqlFile(sqls.ToString()); Console.WriteLine(sqls); Console.WriteLine("Successful."); Console.ReadLine(); }
// public static int BulkInsertWitTransation <T>(List <T> entity, string tableName, MySqlTransaction tran) where T : class { string sql = SqlBuilderHelper.BulkInsertSql(entity, tableName); return(ExecuteNonQuery(tran, CommandType.Text, sql)); }