O'Reilly logo

MVVM Survival Guide for Enterprise Architectures in Silverlight and WPF by Muhammad Shujaat Siddiqi, Ryan Vice

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required