title: Cascading Properties in Entity Framework via Repository Pattern
body: <p>Say I have a class Person that has an "IsArchived" property.  A Person can have a Collection - each of which can also be Archived.  </p>
  
  <p>Right now I have an UpdatePerson method in my repository that looks like this: </p>
  
  <pre><code>    public Person UpdatePerson(Person person)
      {
          _db.Persons.Attach(person);
          var entry = _db.Entry(person);
          entry.Property(e =&gt; e.Name).IsModified = true;
          entry.Property(e =&gt; e.Friends).IsModified = true;
          SaveChanges();
          return entry.Entity;
      }
  </code></pre>
  
  <p>And I have a separate Repository method for Archive: </p>
  
  <pre><code>    public void ArchivePerson(int personId)
      {
          var person = _db.Persons.FirstOrDefault(c =&gt; c.PersonId == personId);
          if (person != null)
          {
              person.IsArchived = true;
  
              foreach (var friend in person.Friends)
              {
                  ArchivePerson(friend.PersonId);
              }
  
              SaveChanges();
          }
      }
  </code></pre>
  
  <p>This means that from my WebAPI, I have to dedicate a function to Archiving/Unarchiving.  It would be cool if I could just call Update and set the Archived for the given entity, and apply this to all child entities where possible.  Is there any way to accomplish this, or am I best off sticking to the ArchivePerson repository method? </p>