I have a fairly complex LINQ to Entities query I'd like to try compiling because it's a bit slower than I'd like.
I build it in a series of steps though. Here's a simple example:
public static List<Employee> GetEmployees(EntityContext ctx, bool showTerminated)
{
var q = ctx.Employees;
if(showTerminated==false)
{
q = q.Where(e => e.TerminationDt == null);
}
//...more conditional filters / Group By / Select applied...
return q.ToList();
}
Is there any way to take advantage of compiled queries when you have this type of conditional query composition?