コード例 #1
0
        private IColumnMappingCollection CreateColumnMappingFromDefinition()
        {
            var mapping = new DataColumnMappingCollection();

            foreach (var col in Definition.Columns)
            {
                if (!col.IsIdentity || KeepIdentity)
                {
                    if (DataIndexForColumn.Count > 0)
                    {
                        if (DataIndexForColumn.ContainsKey(col.Name))
                        {
                            mapping.Add(new DataColumnMapping(col.Name, col.Name));
                        }
                    }
                    else //Default: always a complete mapping
                    {
                        mapping.Add(new DataColumnMapping(col.Name, col.Name));
                    }
                }
            }
            if (mapping.Count == 0)
            {
                throw new ETLBoxException($"Unable to create a column mapping between the destination table {Definition.Name} and input data type." +
                                          $" There were no matching columns found that could be used to write data from the input into the target." +
                                          $" Please check if either the properties of your data type match with the column names (case-sensitive!) or provide a column mapping.");
            }
            return(mapping);
        }
コード例 #2
0
 private void CreateDefaultIndexFromColumnMapping()
 {
     for (int i = 0; i < ColumnMapping.Count; i++)
     {
         DataIndexForColumn.Add(((DataColumnMapping)ColumnMapping[i]).SourceColumn, i);
     }
 }