public void Save(ItemCategory itemCategory) { //Check if itemCategory is in DB var itemCategoryInDb = itemCategoryContext.Get(itemCategory.Id); //If not in DB, create new if (itemCategoryInDb == null) { itemCategoryContext.Add(itemCategory); } //If in DB, update else { itemCategoryInDb.Name = itemCategory.Name; } //Commit changes itemCategoryContext.Commit(); }