public void Scalar_Function_Anonymous_Type_Select_Nested() { using (var context = CreateContext()) { var employeeId = 5; var starCount = 3; var emp = (from e in context.Employees where e.EmployeeID == employeeId select new { e.FirstName, OrderCount = NorthwindDbFunctionContext.StarValue(starCount, NorthwindDbFunctionContext.EmployeeOrderCount(employeeId)) }).Single(); Assert.Equal("Steven", emp.FirstName); Assert.Equal("***42", emp.OrderCount); AssertSql( @"@__starCount_1='3' @__employeeId_2='5' @__employeeId_0='5' SELECT TOP(2) [e].[FirstName], [dbo].StarValue(@__starCount_1, [dbo].EmployeeOrderCount(@__employeeId_2)) AS [OrderCount] FROM [Employees] AS [e] WHERE [e].[EmployeeID] = @__employeeId_0"); } }
public void Scalar_Function_Let_Not_Parameter() { var employeeId = 5; using (var context = CreateContext()) { var emp = (from e in context.Employees let orderCount = NorthwindDbFunctionContext.EmployeeOrderCount(employeeId) where e.EmployeeID == employeeId select new { e.FirstName, OrderCount = orderCount }).Single(); Assert.Equal("Steven", emp.FirstName); Assert.Equal(42, emp.OrderCount); AssertSql( @"@__employeeId_0='5' @__employeeId_1='5' SELECT TOP(2) [e].[FirstName], [dbo].EmployeeOrderCount(@__employeeId_0) AS [OrderCount] FROM [Employees] AS [e] WHERE [e].[EmployeeID] = @__employeeId_1"); } }
public void Scalar_Function_ClientEval_Method_As_Translateable_Method_Parameter() { using (var context = CreateContext()) { Assert.Throws <NotImplementedException>(() => (from e in context.Employees where e.EmployeeID == 5 select new { e.FirstName, OrderCount = NorthwindDbFunctionContext.EmployeeOrderCount(AddFive(e.EmployeeID - 5)) }).Single()); } }
public void Scalar_Function_Constant_Parameter() { using (var context = CreateContext()) { var employeeId = 5; var emps = context.Employees.Select(e => NorthwindDbFunctionContext.EmployeeOrderCount(employeeId)).ToList(); Assert.Equal(9, emps.Count); AssertSql( @"@__employeeId_0='5' SELECT [dbo].EmployeeOrderCount(@__employeeId_0) FROM [Employees] AS [e]"); } }
public void Scalar_Function_Anonymous_Type_Select_Not_Correlated() { using (var context = CreateContext()) { var emp = (from e in context.Employees where e.EmployeeID == 5 select new { e.FirstName, OrderCount = NorthwindDbFunctionContext.EmployeeOrderCount(5) }).Single(); Assert.Equal("Steven", emp.FirstName); Assert.Equal(42, emp.OrderCount); AssertSql( @"SELECT TOP(2) [e].[FirstName], [dbo].EmployeeOrderCount(5) AS [OrderCount] FROM [Employees] AS [e] WHERE [e].[EmployeeID] = 5"); } }