/// <summary> /// Deprecated Method for adding a new object to the Subscriber EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSubscriber(Subscriber subscriber) { base.AddObject("Subscriber", subscriber); }
/// <summary> /// Create a new Subscriber object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="email">Initial value of the Email property.</param> public static Subscriber CreateSubscriber(global::System.Int32 id, global::System.String email) { Subscriber subscriber = new Subscriber(); subscriber.Id = id; subscriber.Email = email; return subscriber; }
public void Subscribe(string subscr) { using (var context = new ModelContainer()) { var exist = context.Subscriber.FirstOrDefault(s => s.Email == subscr); if (exist != null) return; var subscriber = new Subscriber {Email = subscr}; context.AddToSubscriber(subscriber); context.SaveChanges(); } }