Example #1
0
        internal static TResult GetEntityByKey <T, TResult>(this IIdentityMap identityMap, Func <SortedDictionary <string, object> > getKey, out string hash)
            where T : class
            where TResult : class
        {
            hash = null;

            if (identityMap != null)
            {
                var primaryKeyValue = getKey();
                hash = primaryKeyValue.ComputeHash(typeof(T));

                if (identityMap.TryGetValue(hash, out object result))
                {
                    return((TResult)result);
                }
            }

            return(default(TResult));
        }