From e3de81109eacfda943b6c04a74d1a34a92ea368d Mon Sep 17 00:00:00 2001 From: garyhuntddn Date: Tue, 14 Jan 2014 14:29:40 +0000 Subject: [PATCH] provision of TypeMapProvider to allow lazy creation of type maps only when they are needed --- Dapper NET40/SqlMapper.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Dapper NET40/SqlMapper.cs b/Dapper NET40/SqlMapper.cs index 24c78f6d8..228a0562c 100644 --- a/Dapper NET40/SqlMapper.cs +++ b/Dapper NET40/SqlMapper.cs @@ -2154,6 +2154,12 @@ static readonly MethodInfo .Where(p => p.GetIndexParameters().Any() && p.GetIndexParameters()[0].ParameterType == typeof(int)) .Select(p => p.GetGetMethod()).First(); + /// + /// Gets type-map for the given type + /// + /// Type map instance, default is to create new instance of DefaultTypeMap + public static Func TypeMapProvider = ( Type type ) => new DefaultTypeMap( type ); + /// /// Gets type-map for the given type /// @@ -2170,7 +2176,7 @@ public static ITypeMap GetTypeMap(Type type) map = (ITypeMap)_typeMaps[type]; if (map == null) { - map = new DefaultTypeMap(type); + map = TypeMapProvider( type ); _typeMaps[type] = map; } }