title: extension for DbSet
body: <p>What is extension for DbSet? I want to add method 'FindTheLatest'. this is my code:
  this is my code</p>
  
  <pre>
      public static List FindTheLatest(this DbSet&lt;Review> reviews, int nums)
      {
          return reviews.OrderByDescending(r => r.Created).Take(nums).ToList();
      }
  </pre>
  
  <p>But it doesn't work. What i must to do?</p>
  
  <p>this is my extension class:</p>
  
  <pre><code>public static class RestaurantReviewsExtenstion
  {
      public static IEnumerable&lt;Review&gt; FindTheLatest(this IQueryable&lt;Review&gt; reviews, int nums)
      {
          return reviews.OrderByDescending(r =&gt; r.Created).Take(nums).ToList();
      }
  
      public static Review FindById(this System.Data.Entity.DbSet&lt;Review&gt; reviews, int id)
      {
          return reviews.SingleOrDefault(s =&gt; s.ReviewId == id);
          //return reviews.Find(item =&gt; item.Id == id);
      }
  
      public static Review FindTheBest(this List&lt;Review&gt; list)
      {
          return list.OrderByDescending(o =&gt; o.Rating).FirstOrDefault();
      }
  }
  </code></pre>
  
  <p>this is my DBContex Class:</p>
  
  <pre><code>public class OdeToFoodDb: DbContext
  {
      public DbSet&lt;Restaurant&gt; Restaurants { get; set; }
      public DbSet&lt;Review&gt; Reviews { get; set; }
  
      protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;Restaurant&gt;()
              .HasMany(resturant =&gt; resturant.Reviews)
              .WithRequired(review =&gt; review.Resturant);
          base.OnModelCreating(modelBuilder);
      }
  }
  </code></pre>
  
  <p>this is where i get error:</p>
  
  <pre><code>    OdeToFoodDb _db = new OdeToFoodDb();
      public PartialViewResult LatestReview()
      {
          System.Threading.Thread.Sleep(1500);
          //this is where i get error
          var review = _db.Reviews.FindTheLatest(1);
          //************************************
          return PartialView("_Review", review);
      }
  </code></pre>
  
  <p>Sorry about poor information.</p>