title: Why use Repository Pattern or please explain it to me?
body: <p>I am learning repository pattern and was reading <a href="http://www.codeproject.com/Tips/309753/Repository-Pattern-with-Entity-Framework-4-1-and-C" rel="noreferrer">Repository Pattern with Entity Framework 4.1 and Code First
  </a> and <a href="http://www.tugberkugurlu.com/archive/generic-repository-pattern-entity-framework-asp-net-mvc-and-unit-testing-triangle" rel="noreferrer">Generic Repository Pattern - Entity Framework, ASP.NET MVC and Unit Testing Triangle
  </a> about how they implement the repository pattern with Entity Framework.</p>
  
  <p>Saying </p>
  
  <blockquote>
    <p>•Hide EF from upper layer<br>
    •Make code better testable</p>
  </blockquote>
  
  <p>Make code better testable I do understand, but why hide EF from upper layer?</p>
  
  <p>Looking at their implementation, it seems just wrap the entity framework with a generic method for query the entity framework.  Actually what's the reason for doing this?</p>
  
  <p>I am assuming is for </p>
  
  <ol>
  <li>Loose coupling (that's why hide EF from upper layer?) </li>
  <li>Avoid repeat writting same LINQ statement for same query</li>
  </ol>
  
  <p>Am I understand this correctly?  </p>
  
  <p>If I write a DataAccessLayer which is a class have methods</p>
  
  <pre><code>QueryFooObject(int id)
  {
  ..//query foo from entity framework
  } 
  
  AddFooObject(Foo obj)
  {
  .. //add foo to entity framework
  }
  ......
  QueryBarObject(int id)
  {
  ..
  }
  
  AddBarObject(Bar obj)
  {
  ...
  }
  </code></pre>
  
  <p>Is that also a Repository Pattern?</p>
  
  <p>Explaination for dummy will be great :)</p>