title: Entity Framework Best Practices In Business Logic?
body: <p>I am using the Entity framework for the first time, and would like to know if I am using in the best practice.  </p>
  
  <p>I have created a separate class in my business logic which will handle the entity context. the problem I have, is in all the videos I have seen they usually wrap the context in a using statement to make sure its closed, but obviously I can't do this in my business logic as the context will be closed before I can actually use it? </p>
  
  <p>So is this ok what I'm doing?  A couple of examples:</p>
  
  <pre><code>    public IEnumerable&lt;Article&gt; GetLatestArticles(bool Authorised) 
      {
          var ctx = new ArticleNetEntities();
          return ctx.Articles.Where(x =&gt; x.IsApproved == Authorised).OrderBy(x =&gt; x.ArticleDate);
      }
  
      public IEnumerable&lt;Article&gt; GetArticlesByMember(int MemberId, bool Authorised)
      {
          var ctx = new ArticleNetEntities();
          return ctx.Articles.Where(x =&gt; x.MemberID == MemberId &amp;&amp; x.IsApproved == Authorised).OrderBy(x =&gt; x.ArticleDate);
      }
  </code></pre>
  
  <p>I just want to make sure I'm not building something that's going to die when a lot of people use it? </p>