Listing the customers

The next thing we need to do is to get a list of customers to display in the UI. Our approach will be to create a data provider that will query the entity framework to get our entities, which we will use as our models. To accomplish this, follow these steps:

  1. Add a project reference from Northwind.ViewModel to Northwind.Data.
  2. Add a .NET reference to System.Data.Entity.
  3. Add using statements for System.Collections.Generic, Northwind.Data, and System.Data.Objects to MainWindowViewModel.
  4. Add the following code to MainWindowViewModel:
    private IList<Customer> _customers; public IList<Customer> Customers { get { if (_customers == null) { GetCustomers(); } return _customers; } } private void GetCustomers() { _customers = new NorthwindEntities() ...

Get MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.