Skip to content

Commit

Permalink
Fix Cache Key. Use Mapper Type Instead of Instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Curlack committed Nov 4, 2023
1 parent 63c885c commit 2279cf9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PetaPoco/Core/PocoData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class PocoData
{
private static readonly object _converterLock = new object();

private static Cache<Tuple<IMapper, Type>, PocoData> _pocoDatas = new Cache<Tuple<IMapper, Type>, PocoData>();
private static Cache<Tuple<Type, Type>, PocoData> _pocoDatas = new Cache<Tuple<Type, Type>, PocoData>();
private static List<Func<object, object>> _converters = new List<Func<object, object>>();
private static MethodInfo fnGetValue = typeof(IDataRecord).GetMethod("GetValue", new Type[] { typeof(int) });
private static MethodInfo fnIsDBNull = typeof(IDataRecord).GetMethod("IsDBNull");
Expand Down Expand Up @@ -125,7 +125,7 @@ public static PocoData ForType(Type type, IMapper defaultMapper)
if (type == typeof(System.Dynamic.ExpandoObject))
throw new InvalidOperationException("Cannot use dynamic types with this method");

var key = new Tuple<IMapper, Type>(Mappers.GetMapper(type, defaultMapper), type);
var key = new Tuple<Type, Type>(Mappers.GetMapper(type, defaultMapper).GetType(), type);
return _pocoDatas.GetOrAdd(key, () => new PocoData(type, defaultMapper));
}

Expand Down

0 comments on commit 2279cf9

Please sign in to comment.