Exemple #1
0
 private static bool FlushAccumulator(StringBuilder sql_accumulator)
 {
     try {
         string raw = sql_accumulator.ToString();
         if (raw.Length > 0)
         {
             string inserts  = raw.Substring(0, raw.Length - 1); // Trim trailing comma
             var    prefix   = $"Insert Into [{table_Name}] ({ BillRow.Columns()}) Values";
             string nonQuery = prefix + inserts + ";";
             sql_accumulator.Clear();
             DB.NonQuery(nonQuery, "BillRowsTable.FlushAccumulator");
             Log.Instance.Info($"BillRowsTable.FlushAccumulator wrote {SQL_INSERT_ROW_LIMIT} rows.");
         }
     } catch (SqlException sql) {
         Log.Instance.Info($"BillRowsTable.FlushAccumulator: {sql.Message}");
         throw;
     } catch (Exception e) {
         Log.Instance.Info($"BillRowsTable.FlushAccumulator: {e.Message}");
         throw;
     }
     return(true);
 }
Exemple #2
0
        public static void Insert(BillRow row, StringBuilder sql_accumulator)
        {
            var non_query = $"Insert Into [{table_Name}] ({BillRow.Columns()}) Values ({BillRow.RowToColumns(row)});";

            DB.NonQuery(non_query, "BillRowsTable.Insert");
        }