public void Scalar_Function_Where_Nested()
        {
            using (var context = CreateContext())
            {
                var emp = (from e in context.Employees
                           where e.EmployeeID == NorthwindDbFunctionContext.GetEmployeeWithMostOrdersAfterDate(
                               NorthwindDbFunctionContext.GetReportingPeriodStartDate(
                                   NorthwindDbFunctionContext.ReportingPeriod.Winter))
                           select e).SingleOrDefault();

                Assert.NotNull(emp);
                Assert.True(emp.EmployeeID == 4);

                AssertSql(
                    @"SELECT TOP(2) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title]
FROM [Employees] AS [e]
WHERE [e].[EmployeeID] = [dbo].GetEmployeeWithMostOrdersAfterDate([dbo].GetReportingPeriodStartDate(0))");
            }
        }
        public void Scalar_Function_Where_Not_Correlated()
        {
            using (var context = CreateContext())
            {
                var startDate = DateTime.Parse("1/1/1998");

                var emp = (from e in context.Employees
                           where NorthwindDbFunctionContext.GetEmployeeWithMostOrdersAfterDate(startDate) == e.EmployeeID
                           select e).SingleOrDefault();

                Assert.NotNull(emp);
                Assert.True(emp.EmployeeID == 4);

                AssertSql(
                    @"@__startDate_0='01/01/1998 00:00:00'

SELECT TOP(2) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title]
FROM [Employees] AS [e]
WHERE [dbo].GetEmployeeWithMostOrdersAfterDate(@__startDate_0) = [e].[EmployeeID]");
            }
        }