Example #1
0
        public void AddFoodKeyword(string food)
        {
            try
            {
                using (var entityContext = new LunchEntities())
                {
                    var foodKeyword = new FoodKeyword
                    {
                        Word = food
                    };

                    entityContext.FoodKeywords.AddObject(foodKeyword);
                    entityContext.SaveChanges();
                }
            }
            catch (UpdateException updateException)
            {
                var baseError = updateException.GetBaseException();
                if (baseError.Message.Contains("not unique"))
                {
                    return;
                }

                throw;
            }
        }
 /// <summary>
 /// Create a new FoodKeyword object.
 /// </summary>
 /// <param name="word">Initial value of the Word property.</param>
 public static FoodKeyword CreateFoodKeyword(global::System.String word)
 {
     FoodKeyword foodKeyword = new FoodKeyword();
     foodKeyword.Word = word;
     return foodKeyword;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the FoodKeywords EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFoodKeywords(FoodKeyword foodKeyword)
 {
     base.AddObject("FoodKeywords", foodKeyword);
 }