Skip to content

Commit

Permalink
Exclude object properties from nested mapping (fixes #309)
Browse files Browse the repository at this point in the history
  • Loading branch information
mganss committed Jul 16, 2024
1 parent 274c91a commit cdc4fcd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions ExcelMapper.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3227,5 +3227,20 @@ public void FormatTest()
new IdNumber { IdNo = "8402155792088" }
});
}

record ObjectProduct
{
public object Name { get; set; }
public object Number { get; set; }
}

[Test]
public void ObjectTest()
{
var products = new ExcelMapper(@"../../../xlsx/Products.xlsx").Fetch<ObjectProduct>().ToList();
Assert.That(products.Count, Is.EqualTo(3));
Assert.That(products[0].Name, Is.EqualTo("Nudossi"));
Assert.That(products[0].Number, Is.EqualTo(60));
}
}
}
3 changes: 2 additions & 1 deletion ExcelMapper/ColumnInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ internal void SetPropertyType(Type propertyType)
&& PropertyType != typeof(string)
&& !DateTypes.Contains(PropertyType.FullName)
&& PropertyType != typeof(Guid)
&& PropertyType != typeof(byte[]);
&& PropertyType != typeof(byte[])
&& PropertyType != typeof(object);
}

/// <summary>
Expand Down

0 comments on commit cdc4fcd

Please sign in to comment.