예제 #1
0
        protected void MapProperty <TProperty>(int columnIndex,
                                               Expression <Func <TEntity, TProperty> > mappingExpression)
        {
            var propertyName = GetPropertyNameFromExpression(mappingExpression);
            var mapper       = PropertyMapperFactory.CreateMapper <TEntity>(propertyName);
            var mapping      = new CsvPropertyMapping(columnIndex, mapper);

            _mappings.Insert(columnIndex, mapping);
            _numCols++;
        }
예제 #2
0
        protected CsvPropertyMapping <TEntity, TProperty> MapProperty <TProperty>(int columnIndex, Expression <Func <TEntity, TProperty> > property, ITypeConverter <TProperty> typeConverter)
        {
            if (csvIndexPropertyMappings.Any(x => x.ColumnIndex == columnIndex))
            {
                throw new InvalidOperationException($"Duplicate mapping for column index {columnIndex}");
            }

            var propertyMapping = new CsvPropertyMapping <TEntity, TProperty>(property, typeConverter);

            AddPropertyMapping(columnIndex, propertyMapping);

            return(propertyMapping);
        }