/// 只更新storedAddress数据中的DefaultAddress字段,更新为false /// 将默认地址改为不是默认地址 /// </summary> /// <param name="id">需要修改的对象的id</param> public void Update(int id) { StoredAddress s = new StoredAddress { StoredAddressID = id }; object originalItem = null; System.Data.EntityKey key = _context.CreateEntityKey("StoredAddresses", s); if (_context.TryGetObjectByKey(key, out originalItem)) { _context.Detach(originalItem); } s.DefaultAddress = true; _context.StoredAddresses.Attach(s); s.DefaultAddress = false; _context.SaveChanges(); _context.Detach(s); }