Linq to Entities, Inject Join Inside Query Expression
问题 I'm trying to improve the performance for some of our LINQ queries and there is one little thing that has a lot of space for improvement: joins. Almost all my queries have some join that is used to filter the result, but are not selected into de result. And these filtering conditions are optional... What I have today is something like: var q = from t1 in context.Set<T1>() where t1.mandatoryfilter >= 0 select t1; if (useFilter) { var q2 = from t1 in q from t2 in context.Set<T2>().Where(t2 =>