public void Update(ShopItem valueItem) { ShopItem repositoryItem = Get(valueItem.ArticleNumber); if (repositoryItem == null) { throw new Exception(String.Format("Trying to update an item that does not exist yet: ({0})", valueItem.ToString())); } if (!repositoryItem.Equals(valueItem)) { repositoryItem.Assign(valueItem); } if (!SaveOnClose) { context.Put(repositoryItem); } }