private void AddInternal(TItem item) { if (item == null) { return; } if (ModelRegistry.IsManagedModel(item) && !ModelRegistry.IsManagedBy(Session, item)) { var id = ModelRegistry.GetId(item); throw new UnmanagedModelException(item.GetType(), id); } var itemId = ModelRegistry.GetOrCreateId(item); Session.Cache.Update(itemId, item); if (Ids.Contains(itemId)) { return; } Ids.Add(itemId); IsModified = true; }
private void ThrowIfUnmanaged(object model) { if (ModelRegistry.IsUnmanagedModel(model) || !ModelRegistry.IsManagedBy(this, model)) { throw new UnmanagedModelException(model.GetType(), ModelRegistry.GetId(model)); } }