using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Data.Objects;

namespace AdventureWorksProcs
{
    class Program
    {
        static void Main(string[] args)
        {
            // compare stored procedure execution with LINQ query

            using (AdventureWorksEntities ents = new AdventureWorksEntities())
            {
                ObjectResult<GetOrdersHeader_Result> res = ents.GetOrdersHeader(new DateTime(2004, 07, 31));
                res.ToList();

                DateTime datevar = new DateTime(2004, 07, 31);
                var res2 = from d in ents.SalesOrderDetails
                           join h in ents.SalesOrderHeaders
                           on d.SalesOrderID equals h.SalesOrderID
                           where h.OrderDate == datevar
                           select new {h, d.SalesOrderDetailID};

                res2.ToList();

                // inline value
                var res3 = from d in ents.SalesOrderDetails
                           join h in ents.SalesOrderHeaders
                           on d.SalesOrderID equals h.SalesOrderID
                           where h.OrderDate == new DateTime(2004, 07, 31)
                           select new { h, d.SalesOrderDetailID };

                res3.ToList();
            }

        }
    }
}
