Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

Entity Framework, ToList method missing on Entity Class

If you want to use the ToList() method of an entity you need to import the namespace:
using System.Linq;, else the method will not appear.

Example
using System.Linq;

public class NorthWindDemo {
  private NorthwindEntities _entities = new NorthwindEntities();
  public ActionResult Index()
  {
    return View(_entities.ProductSet.ToList());
  }
}
Entity Framework, ToList method missing on Entity Class Entity Framework, ToList method missing on Entity Class Reviewed by Edward Legaspi on Sunday, December 05, 2010 Rating: 5

1 comment:

Anonymous said...

Perfect!

Powered by Blogger.