text: Q:
  
  Update an EntityObject with an another EntityObject
  
  I have a little problem and I need your help with it. I'm using Entity Framework for database handling and I want to update a dataset in this database.
  I have an EntityObject with all the changes and want to be able to update this Object with  existing Object.
  I'm using the following code to update the data:
  IQueryable<Competitors> getCompetitor = DatabaseObject.Competitors.Where(SelectOnly => SelectOnly.competitorID == competitorObject.competitorID);
  Competitors competitor = getCompetitor.First();
  competitor = competitorObject;
  DatabaseObject.SaveChanges();
  
  But this deosn't work. How can I update the date in database?
  
  A:
  
  Assuming, that your competitorObject is of Competitors type (competitor = competitorObject), you have to attach it to your context, mark it as modified, and then save changes:
  DatabaseObject.Competitors.Attach(competitorObject);
  DatabaseObject.Entry(competitorObject).State = EntityState.Modified;
  DatabaseObject.SaveChanges();
  
  There's no need to retrieve source object in your case, but without attaching, the context knows nothing about your updated object.
  The piece of code, which is marking an object as modified, can be a little different, if you're using ObjectContext API instead of DbContext API:
  DatabaseObject.ObjectStateManager.GetObjectStateEntry(competitorObject).SetModified();
  
  