/// <exception cref="InvalidOperationException"> /// Attempt to associate non-null <paramref name="tuple"/> with <paramref name="key"/> of unknown type. /// </exception> internal EntityState UpdateStateInCache(Key key, Tuple tuple, bool isStale) { var result = EntityStateCache[key, true]; if (result == null) { if (!key.HasExactType && tuple != null) { throw Exceptions.InternalError( Strings.ExCannotAssociateNonEmptyEntityStateWithKeyOfUnknownType, OrmLog.Instance); } result = AddEntityStateToCache(key, tuple, isStale); SystemEvents.NotifyEntityMaterialized(result); Events.NotifyEntityMaterialized(result); } else { if (!result.Key.HasExactType && key.HasExactType) { EntityStateCache.RemoveKey(result.Key); result = AddEntityStateToCache(key, tuple, result.IsStale); } result.Update(tuple); result.IsStale = isStale; if (IsDebugEventLoggingEnabled) { OrmLog.Debug(Strings.LogSessionXUpdatingCacheY, this, result); } } return(result); }
internal void RemoveStateFromCache(Key key, bool removeFromInnerCache = false) { EntityStateCache.RemoveKey(key, removeFromInnerCache); }