public IQueryable <CallTreeNode> Execute(SQLiteQueryProvider provider, QueryExecutionOptions options) { StringBuilder b = new StringBuilder(); SqlQueryContext context = new SqlQueryContext(provider); BuildSql(b, context); if (options.HasLoggers) { options.WriteLogLine(b.ToString()); } Stopwatch w = Stopwatch.StartNew(); IList <CallTreeNode> result = provider.RunSQLNodeList(b.ToString(), context.HasIDList); w.Stop(); if (options.HasLoggers) { options.WriteLogLine("Query returned " + result.Count + " rows in " + w.Elapsed); } return(result.AsQueryable()); }
public override object Execute(Expression inputExpression) { Stopwatch watch = Stopwatch.StartNew(); Expression partiallyEvaluatedExpression = PartialEvaluator.Eval(inputExpression, CanBeEvaluatedStatically); QueryExecutionOptions options = new QueryExecutionOptions(); Expression expression = new ConvertToQueryAstVisitor(options).Visit(partiallyEvaluatedExpression); // options have been initialized by ConvertToQueryAstVisitor, start logging: if (options.HasLoggers) { options.WriteLogLine("Input expression: " + inputExpression); options.WriteLogLine("Partially evaluated expression: " + partiallyEvaluatedExpression); options.WriteLogLine("Converted to Query AST: " + expression); } expression = new OptimizeQueryExpressionVisitor().Visit(expression); if (options.HasLoggers) { options.WriteLogLine("Optimized Query AST: " + expression); options.WriteLogLine("Query preparation time: " + watch.Elapsed); } object result; // If the whole query was converted, execute it: QueryNode query = expression as QueryNode; if (query != null) { result = query.Execute(this, options); } else { // Query not converted completely: we have to use a LINQ-To-Objects / LINQ-To-Profiler mix expression = new ExecuteAllQueriesVisitor(this, options).Visit(expression); if (expression.Type.IsValueType) { expression = Expression.Convert(expression, typeof(object)); } var lambdaExpression = Expression.Lambda <Func <object> >(expression); result = lambdaExpression.Compile()(); } watch.Stop(); options.WriteLogLine("Total query execution time: " + watch.Elapsed); return(result); }
public IQueryable<CallTreeNode> Execute(SQLiteQueryProvider provider, QueryExecutionOptions options) { StringBuilder b = new StringBuilder(); SqlQueryContext context = new SqlQueryContext(provider); BuildSql(b, context); if (options.HasLoggers) options.WriteLogLine(b.ToString()); Stopwatch w = Stopwatch.StartNew(); IList<CallTreeNode> result = provider.RunSQLNodeList(b.ToString(), context.HasIDList); w.Stop(); if (options.HasLoggers) { options.WriteLogLine("Query returned " + result.Count + " rows in " + w.Elapsed); } return result.AsQueryable(); }
public override object Execute(Expression inputExpression) { Stopwatch watch = Stopwatch.StartNew(); Expression partiallyEvaluatedExpression = PartialEvaluator.Eval(inputExpression, CanBeEvaluatedStatically); QueryExecutionOptions options = new QueryExecutionOptions(); Expression expression = new ConvertToQueryAstVisitor(options).Visit(partiallyEvaluatedExpression); // options have been initialized by ConvertToQueryAstVisitor, start logging: if (options.HasLoggers) { options.WriteLogLine("Input expression: " + inputExpression); options.WriteLogLine("Partially evaluated expression: " + partiallyEvaluatedExpression); options.WriteLogLine("Converted to Query AST: " + expression); } expression = new OptimizeQueryExpressionVisitor().Visit(expression); if (options.HasLoggers) { options.WriteLogLine("Optimized Query AST: " + expression); options.WriteLogLine("Query preparation time: " + watch.Elapsed); } object result; // If the whole query was converted, execute it: QueryNode query = expression as QueryNode; if (query != null) { result = query.Execute(this, options); } else { // Query not converted completely: we have to use a LINQ-To-Objects / LINQ-To-Profiler mix expression = new ExecuteAllQueriesVisitor(this, options).Visit(expression); if (expression.Type.IsValueType) { expression = Expression.Convert(expression, typeof(object)); } var lambdaExpression = Expression.Lambda<Func<object>>(expression); result = lambdaExpression.Compile()(); } watch.Stop(); options.WriteLogLine("Total query execution time: " + watch.Elapsed); return result; }