From cdc4fcdc17cb63963b08a9f54e0d3f88c2cdf65c Mon Sep 17 00:00:00 2001 From: Michael Ganss Date: Tue, 16 Jul 2024 19:13:37 +0200 Subject: [PATCH] Exclude object properties from nested mapping (fixes #309) --- ExcelMapper.Tests/Tests.cs | 15 +++++++++++++++ ExcelMapper/ColumnInfo.cs | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ExcelMapper.Tests/Tests.cs b/ExcelMapper.Tests/Tests.cs index 9f162ed..13f5aaf 100644 --- a/ExcelMapper.Tests/Tests.cs +++ b/ExcelMapper.Tests/Tests.cs @@ -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().ToList(); + Assert.That(products.Count, Is.EqualTo(3)); + Assert.That(products[0].Name, Is.EqualTo("Nudossi")); + Assert.That(products[0].Number, Is.EqualTo(60)); + } } } diff --git a/ExcelMapper/ColumnInfo.cs b/ExcelMapper/ColumnInfo.cs index b58e2a0..7f26a68 100644 --- a/ExcelMapper/ColumnInfo.cs +++ b/ExcelMapper/ColumnInfo.cs @@ -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); } ///