Skip to content

Commit 0fc522e

Browse files
committed
Merge branch 'move-getidproperty' into cache-propmaps-issue23
2 parents 49d45e4 + d79f6ba commit 0fc522e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

JSONAPI/Core/ModelManager.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,19 @@ public PropertyInfo GetIdProperty(Type type)
4848

4949
var idPropCache = _idProperties.Value;
5050

51-
if (idPropCache.TryGetValue(type, out idprop)) return idprop;
52-
53-
//TODO: Enable attribute-based determination
51+
lock (idPropCache)
52+
{
53+
if (idPropCache.TryGetValue(type, out idprop)) return idprop;
54+
55+
//TODO: Enable attribute-based determination
5456

55-
idprop = type.GetProperty("Id");
57+
idprop = type.GetProperty("Id");
5658

57-
if (idprop == null)
58-
throw new InvalidOperationException(String.Format("Unable to determine Id property for type {0}", type));
59+
if (idprop == null)
60+
throw new InvalidOperationException(String.Format("Unable to determine Id property for type {0}", type));
5961

60-
_idProperties.Value.Add(type, idprop);
62+
idPropCache.Add(type, idprop);
63+
}
6164

6265
return idprop;
6366
}

0 commit comments

Comments
 (0)