diff --git a/src/AddIns/Misc/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs b/src/AddIns/Misc/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs
index cb35ee7c69..245ee7b8c6 100644
--- a/src/AddIns/Misc/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs
+++ b/src/AddIns/Misc/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs
@@ -162,6 +162,17 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
return expression.ToString();
}
+ ///
+ /// Optimizes the query without executing it.
+ /// Used for unit tests.
+ ///
+ public Expression OptimizeQuery(Expression inputExpression)
+ {
+ Expression partiallyEvaluatedExpression = PartialEvaluator.Eval(inputExpression, CanBeEvaluatedStatically);
+ Expression expression = new ConvertToQueryAstVisitor(new QueryExecutionOptions()).Visit(partiallyEvaluatedExpression);
+ return new OptimizeQueryExpressionVisitor().Visit(expression);
+ }
+
public override object Execute(Expression inputExpression)
{
Stopwatch watch = Stopwatch.StartNew();
diff --git a/src/AddIns/Misc/Profiler/Controller/ExtensionMethods.cs b/src/AddIns/Misc/Profiler/Controller/ExtensionMethods.cs
index 7b01225ea1..16e947d78e 100644
--- a/src/AddIns/Misc/Profiler/Controller/ExtensionMethods.cs
+++ b/src/AddIns/Misc/Profiler/Controller/ExtensionMethods.cs
@@ -105,8 +105,11 @@ namespace ICSharpCode.Profiler.Controller
if (logOutput == null)
throw new ArgumentNullException("logOutput");
- logOutput.WriteLine("The query did not use LINQ-to-Profiler.");
+ IQueryable query = items as IQueryable;
+ if (query != null)
+ return query.WithQueryLog(logOutput);
+ logOutput.WriteLine("The query did not use LINQ-to-Profiler.");
return items;
}
diff --git a/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs b/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs
index 3967c216e0..ca36431543 100644
--- a/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs
+++ b/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs
@@ -292,7 +292,7 @@ namespace ICSharpCode.Profiler.Controls
{
try {
if (compiler.Compile()) {
- var data = compiler.ExecuteQuery(provider, rangeStart, rangeEnd);
+ IEnumerable data = compiler.ExecuteQuery(provider, rangeStart, rangeEnd);
#if DEBUG
data = data.WithQueryLog(Console.Out);
#endif