Ejemplo n.º 1
0
        private void SqlDeleteIds(IEnumerable <TInput> rowsToDelete)
        {
            if (rowsToDelete == null || rowsToDelete?.Count() == 0)
            {
                return;
            }

            TableDefinition idColsOnly = new TableDefinition();

            if (DestinationTableDefinition == null)
            {
                DestinationTableDefinition = TableDefinition.FromTableName(this.DbConnectionManager, TableName);
            }
            IdColumnNames.ForEach(idcol =>
                                  idColsOnly.Columns.Add(DestinationTableDefinition.Columns.Where(col => col.Name == idcol).FirstOrDefault()));
            idColsOnly.Name = TableName;
            TableData data = new TableData(idColsOnly);

            foreach (var row in rowsToDelete)
            {
                data.Rows.Add(GetIdColumnValues(row).ToArray());
            }
            SqlTask.BulkDelete(this.ConnectionManager, data, TableName);
        }