Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Dapper/SqlMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,19 @@ private static void PassByPosition(IDbCommand cmd)
});
}

private static bool IsRegisteredType(Type type)
{
if (type == null)
{
return false;
}

Type underlyingType = null;

return typeMap.ContainsKey(type) || type.IsEnum() || type.FullName == LinqBinary
|| (type.IsValueType() && (underlyingType = Nullable.GetUnderlyingType(type)) != null && underlyingType.IsEnum());
}

private static Func<IDataReader, object> GetDeserializer(Type type, IDataReader reader, int startBound, int length, bool returnNullIfFirstMissing)
{
// dynamic is passed in as Object ... by c# design
Expand All @@ -1775,8 +1788,7 @@ private static Func<IDataReader, object> GetDeserializer(Type type, IDataReader
return GetDapperRowDeserializer(reader, startBound, length, returnNullIfFirstMissing);
}
Type underlyingType = null;
if (!(typeMap.ContainsKey(type) || type.IsEnum() || type.FullName == LinqBinary
|| (type.IsValueType() && (underlyingType = Nullable.GetUnderlyingType(type)) != null && underlyingType.IsEnum())))
if (!(IsRegisteredType(type) || (type.IsArray && IsRegisteredType(type.GetElementType()))))
{
if (typeHandlers.TryGetValue(type, out ITypeHandler handler))
{
Expand Down