title: Saving in entity framework
body: <p>I have read <a href="http://www.codeproject.com/Tips/309753/Repository-Pattern-with-Entity-Framework-4-1-and-C" rel="noreferrer">this</a> article and still misunderstanding key moments. Don't we need call</p>
  
  <pre><code>_context.SaveChanges()
  </code></pre>
  
  <p>in every Delete/Update/... operations?</p>
  
  <p>If I change property of any entity does <code>SaveChanges()</code> submitted result to database or I must manually set <code>EntityState.Modifyed</code>?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class Repository&lt;T&gt; : IRepository&lt;T&gt; 
      where T : class
  {
      private IDbContext _context;
  
      public Repository(IDbContext context)
      {
          _context = context;
      }
  
      private IDbSet&lt;T&gt; DbSet
      {
          get
          {
              return _context.Set&lt;T&gt;();
          }
      }
  
      #region IRepository&lt;T&gt; Members
  
      public void Insert(T entity)
      {
          DbSet.Add(entity);
      }
  
      public void Delete(T entity)
      {
          DbSet.Remove(entity);
      }
  
      public IQueryable&lt;T&gt; SearchFor(Expression&lt;Func&lt;T, bool&gt;&gt; predicate)
      {
          return DbSet.Where(predicate);
      }
  
      public IQueryable&lt;T&gt; GetAll()
      {
          return DbSet;
      }
  
      public T GetById(int id)
      {
          return DbSet.Find(id);
      }
      #endregion
  }
  
  public interface IDbContext
  {
      IDbSet&lt;T&gt; Set&lt;T&gt;() where T : class;
  
      int SaveChanges();
      void Dispose();
  }
  </code></pre>