public void UpdateContact(Contact c) { using (var e = new AdventureWorksEntities()) { e.Attach(e.Contacts.Single(x => x.ContactID == c.ContactID)); e.ApplyCurrentValues("Contacts", c); e.SaveChanges(); } }
public void DeleteContact(Contact c) { if (c == null) return; using (var e = new AdventureWorksEntities()) { e.Attach(c); e.DeleteObject(c); e.SaveChanges(); } }
public int InsertContact(Contact c) { var retorno = 0; using (var e = new AdventureWorksEntities()) { e.AddObject("Contacts", c); e.SaveChanges(); retorno = c.ContactID; } return retorno; }
/// <summary> /// Deprecated Method for adding a new object to the Contacts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToContacts(Contact contact) { base.AddObject("Contacts", contact); }
/// <summary> /// Create a new Contact object. /// </summary> /// <param name="contactID">Initial value of the ContactID property.</param> /// <param name="nameStyle">Initial value of the NameStyle property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="emailPromotion">Initial value of the EmailPromotion property.</param> /// <param name="passwordHash">Initial value of the PasswordHash property.</param> /// <param name="passwordSalt">Initial value of the PasswordSalt property.</param> /// <param name="rowguid">Initial value of the rowguid property.</param> /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param> public static Contact CreateContact(global::System.Int32 contactID, global::System.Boolean nameStyle, global::System.String firstName, global::System.String lastName, global::System.Int32 emailPromotion, global::System.String passwordHash, global::System.String passwordSalt, global::System.Guid rowguid, global::System.DateTime modifiedDate) { Contact contact = new Contact(); contact.ContactID = contactID; contact.NameStyle = nameStyle; contact.FirstName = firstName; contact.LastName = lastName; contact.EmailPromotion = emailPromotion; contact.PasswordHash = passwordHash; contact.PasswordSalt = passwordSalt; contact.rowguid = rowguid; contact.ModifiedDate = modifiedDate; return contact; }