Piotr Czajkowski 1 gadu atpakaļ
vecāks
revīzija
d67d18a414
1 mainītis faili ar 5 papildinājumiem un 5 dzēšanām
  1. 5 5
      ExcelORM/ExcelORM/Mapping.cs

+ 5 - 5
ExcelORM/ExcelORM/Mapping.cs

@@ -5,7 +5,6 @@ namespace ExcelORM
     public class Mapping
     {
         public string? PropertyName { get; set; }
-        public Type? PropertyType { get; set; }
         public int? Position { get; set; }
 
         public static List<Mapping>? MapProperties<T>(IXLCells? headerCells) where T : new()
@@ -17,12 +16,13 @@ namespace ExcelORM
             var properties = objectToRead.GetType().GetProperties();
             foreach (var property in properties)
             {
-                int? position = null;
-                var columnAttribute = property.GetCustomAttributes(typeof(ColumnAttribute), false).FirstOrDefault() as ColumnAttribute;
-                position = columnAttribute is { Names.Length: > 0 } ? headerCells.FirstOrDefault(x => !x.Value.IsBlank && Array.Exists(columnAttribute.Names, y => y.Equals(x.Value.ToString(), StringComparison.InvariantCultureIgnoreCase)))?.Address.ColumnNumber : headerCells.FirstOrDefault(x => !x.Value.IsBlank && x.Value.ToString().Equals(property.Name, StringComparison.InvariantCultureIgnoreCase))?.Address.ColumnNumber;
+                var position = property.GetCustomAttributes(typeof(ColumnAttribute), false).FirstOrDefault() is ColumnAttribute { Names.Length: > 0 } columnAttribute
+                    ?
+                    headerCells.FirstOrDefault(x => !x.Value.IsBlank && Array.Exists(columnAttribute.Names, y => y.Equals(x.Value.ToString(), StringComparison.InvariantCultureIgnoreCase)))?.Address.ColumnNumber
+                    : headerCells.FirstOrDefault(x => !x.Value.IsBlank && x.Value.ToString().Equals(property.Name, StringComparison.InvariantCultureIgnoreCase))?.Address.ColumnNumber;
 
                 if (position == null) continue;
-                map.Add(new Mapping { PropertyName = property.Name, PropertyType = property.PropertyType, Position = position });
+                map.Add(new Mapping { PropertyName = property.Name, Position = position });
             }
 
             if (map.Count == properties.Length)