'System.Data.Entity.DbSet`1<Northwind.Data.Customer>' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'System.Data.Entity.DbSet`1<Northwind.Data.Customer>'
private void GetCustomers() { //error in following line _customers = new NORTHWNDEntities().Customers.ToList(); }
using Northwind.Data; using System.Collections.Generic; using System.Data.Entity; using System.Linq; namespace Northwind.ViewModel { public class MainWindowViewModel { private IList<Customer> _customers; public IList<Customer> Customers { get { if (_customers == null) { GetCustomers(); } return _customers; } } private void GetCustomers() { _customers = new NORTHWNDEntities().Customers.ToList(); } } }
namespace Northwind.Data { using System; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Linq; public partial class NORTHWNDEntities : DbContext { public NORTHWNDEntities() : base("name=NORTHWNDEntities"){} protected override void OnModelCreating(DbModelBuilder modelBuilder) { throw new UnintentionalCodeFirstException(); } public virtual DbSet<Customer> Customers { get; set; } public virtual DbSet<Employee> Employees { get; set; } public virtual DbSet<Order_Detail> Order_Details { get; set; } public virtual DbSet<Order> Orders { get; set; } public virtual DbSet<Product> Products { get; set; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)