using System.Collections.ObjectModel;
using System.Windows;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;

namespace DatabaseFirstNorthwind
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = new MainViewModel();
        }
    }

    public class MainViewModel : ViewModelBase
    {
        private QueryableEntityCoreCollectionView<Customer> dataView;

        public MainViewModel()
        {
            this.Context = new NorthwindContext();
        }

        public NorthwindContext Context { get; set; }

        public QueryableEntityCoreCollectionView<Customer> DataView
        {
            get
            {
                if (this.dataView == null)
                {
                    this.dataView = new QueryableEntityCoreCollectionView<Customer>(this.Context, this.Context.Customers, new Collection<string> { "Orders" });
                }

                return this.dataView;
            }
        }
    }
}
