diff --git a/src/Dapper.FluentMap/TypeMaps/FluentTypeMap.cs b/src/Dapper.FluentMap/TypeMaps/FluentTypeMap.cs index 8d99e84..4399803 100644 --- a/src/Dapper.FluentMap/TypeMaps/FluentTypeMap.cs +++ b/src/Dapper.FluentMap/TypeMaps/FluentTypeMap.cs @@ -48,6 +48,14 @@ private static PropertyInfo GetPropertyInfo(Type type, string columnName) TypePropertyMapCache.TryAdd(cacheKey, propertyMap.PropertyInfo); return propertyMap.PropertyInfo; } +#if !NETSTANDARD1_3 + else + { + var ignoredPropertyInfo = new IgnoredPropertyInfo(); + TypePropertyMapCache.TryAdd(cacheKey, ignoredPropertyInfo); + return ignoredPropertyInfo; + } +#endif } } diff --git a/src/Dapper.FluentMap/TypeMaps/IgnoredPropertyInfo.cs b/src/Dapper.FluentMap/TypeMaps/IgnoredPropertyInfo.cs new file mode 100644 index 0000000..b396930 --- /dev/null +++ b/src/Dapper.FluentMap/TypeMaps/IgnoredPropertyInfo.cs @@ -0,0 +1,28 @@ +#if !NETSTANDARD1_3 +using System; +using System.Globalization; +using System.Reflection; + +namespace Dapper.FluentMap.TypeMaps +{ + internal class IgnoredPropertyInfo : PropertyInfo + { + public override Type PropertyType => throw new NotImplementedException(); + public override PropertyAttributes Attributes => throw new NotImplementedException(); + public override bool CanRead => throw new NotImplementedException(); + public override bool CanWrite => throw new NotImplementedException(); + public override string Name => throw new NotImplementedException(); + public override Type DeclaringType => throw new NotImplementedException(); + public override ParameterInfo[] GetIndexParameters() => throw new NotImplementedException(); + public override Type ReflectedType => throw new NotImplementedException(); + public override MethodInfo[] GetAccessors(bool nonPublic) => throw new NotImplementedException(); + public override object[] GetCustomAttributes(bool inherit) => throw new NotImplementedException(); + public override object[] GetCustomAttributes(Type attributeType, bool inherit) => throw new NotImplementedException(); + public override MethodInfo GetGetMethod(bool nonPublic) => throw new NotImplementedException(); + public override MethodInfo GetSetMethod(bool nonPublic) => throw new NotImplementedException(); + public override bool IsDefined(Type attributeType, bool inherit) => throw new NotImplementedException(); + public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) => throw new NotImplementedException(); + public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) => throw new NotImplementedException(); + } +} +#endif \ No newline at end of file diff --git a/src/Dapper.FluentMap/TypeMaps/MultiTypeMap.cs b/src/Dapper.FluentMap/TypeMaps/MultiTypeMap.cs index 86052dc..c548541 100644 --- a/src/Dapper.FluentMap/TypeMaps/MultiTypeMap.cs +++ b/src/Dapper.FluentMap/TypeMaps/MultiTypeMap.cs @@ -103,6 +103,14 @@ public SqlMapper.IMemberMap GetMember(string columnName) var result = mapper.GetMember(columnName); if (result != null) { +#if !NETSTANDARD1_3 + if (result is IgnoredPropertyInfo) + { + // The property is explicitly ignored, + // return null to prevent falling back to default type map of Dapper. + return null; + } +#endif return result; } }