public static void Insert(this TableDefinition definition, DatabaseActions database, TableData tableData)
 {
     if (database == null) throw new ArgumentNullException("database");
     if (tableData == null) throw new ArgumentNullException("tableData");
     if (tableData.ColumnNames == null || !tableData.ColumnNames.Any())
         tableData = new CollectionPopulatedTableData(definition.Columns.Select(x => x.Name).ToList(), tableData.Rows);
     new TableActions(database.ConnectionString).Insert(definition.Name, tableData);
 }
 private string EquivalenceDetails(TableData actual)
 {
     return new StringBuilder()
         .AppendLine("Table data mismatch.")
         .AppendLine("Expected:")
         .Append(ToString())
         .AppendLine("Actual:")
         .Append(actual.ToString())
         .ToString();
 }
        public void Insert(DatabaseObjectName tableName, TableData tableData)
        {
            if (tableName == null) throw new ArgumentNullException(nameof(tableName));
            if (tableData == null) throw new ArgumentNullException(nameof(tableData));

            bool hasColumnNames = tableData.ColumnNames != null && !tableData.ColumnNames.Equals(Enumerable.Empty<string>());
            var generator = new TableInsertSqlGenerator();
            using (var connection = new SqlConnection(connectionString))
            {
                foreach (var row in tableData.Rows)
                {
                    string command = hasColumnNames ? generator.Sql(tableName, tableData.ColumnNames) : generator.Sql(tableName, row.Count());

                    connection.ExecuteWithParameters(command, row);
                }
            }
        }
 public void VerifyMatch(TableData other, TableDataComparers strategy)
 {
     if (!IsMatch(other, new TableDataComparerStrategyFactory().Comparer(strategy))) throw new EquivalenceException(EquivalenceDetails(other));
 }
 public void VerifyMatch(TableData other, TableDataComparer comparer)
 {
     if (!IsMatch(other, comparer)) throw new EquivalenceException(EquivalenceDetails(other));
 }
 public bool IsMatch(TableData other, TableDataComparers strategy)
 {
     return IsMatch(other, new TableDataComparerStrategyFactory().Comparer(strategy));
 }
 public bool IsMatch(TableData other, TableDataComparer comparer)
 {
     if (comparer == null) throw new ArgumentNullException("comparer");
     return comparer.IsMatch(this, other);
 }
 public void Insert(string tableName, TableData tableData)
 {
     Insert(DatabaseObjectName.FromName(tableName), tableData);
 }