From 8e9ac751c9440264325556dffda3522b231341af Mon Sep 17 00:00:00 2001 From: Jiayi Peng Date: Thu, 8 Sep 2022 14:18:05 +0800 Subject: [PATCH] ResolveMember Extension --- LiteDB/Client/Mapper/BsonMapper.cs | 3 ++- LiteDB/Client/Mapper/MemberMapper.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/LiteDB/Client/Mapper/BsonMapper.cs b/LiteDB/Client/Mapper/BsonMapper.cs index 304902b58..4f4f8fbd2 100644 --- a/LiteDB/Client/Mapper/BsonMapper.cs +++ b/LiteDB/Client/Mapper/BsonMapper.cs @@ -328,7 +328,8 @@ protected virtual EntityMapper BuildEntityMapper(Type type) this.ResolveMember?.Invoke(type, memberInfo, member); // test if has name and there is no duplicate field - if (member.FieldName != null && mapper.Members.Any(x => x.FieldName.Equals(name, StringComparison.OrdinalIgnoreCase)) == false) + // when member is not ignore + if (member.FieldName != null && mapper.Members.Any(x => x.FieldName.Equals(name, StringComparison.OrdinalIgnoreCase)) == false && !member.IsIgnore) { mapper.Members.Add(member); } diff --git a/LiteDB/Client/Mapper/MemberMapper.cs b/LiteDB/Client/Mapper/MemberMapper.cs index fe648fb1e..0e199f9cb 100644 --- a/LiteDB/Client/Mapper/MemberMapper.cs +++ b/LiteDB/Client/Mapper/MemberMapper.cs @@ -63,5 +63,10 @@ public class MemberMapper /// When property is an array of items, gets underlying type (otherwise is same type of PropertyType) /// public Type UnderlyingType { get; set; } + + /// + /// Is this property ignore + /// + public bool IsIgnore { get; set; } } } \ No newline at end of file