using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }

    public class MyDataContext
    {
        IQueryable _Data;
        public IQueryable Data
        {
            get
            {
                if (_Data == null)
                {
                    var northwindEntities = new NorthwindEntities();
                    var queryable = from o in northwindEntities.Orders
                                    from od in northwindEntities.Order_Details
                                    select new
                                    {
                                        od.OrderID,
                                        od.ProductID,
                                        od.UnitPrice,
                                        od.Quantity,
                                        od.Discount,
                                        o.CustomerID,
                                        o.EmployeeID,
                                        o.OrderDate
                                    };
                    _Data = queryable.OrderBy(i => i.OrderID);
                }

                return _Data;
            }
        }
    }
}
