public static IEnumerable<SqlStatement> Parse(IQueryContext context, SqlQuery query) { if (query == null) throw new ArgumentNullException("query"); var compiler = DefaultCompiler; ISystemContext systemContext = null; if (context != null) { systemContext = context.SystemContext(); compiler = systemContext.SqlCompiler(); } try { var compileContext = new SqlCompileContext(systemContext, query.Text); var result = compiler.Compile(compileContext); if (result.HasErrors) throw new SqlParseException(); var statements = result.Statements; foreach (var statement in statements) { if (statement != null) statement.SetSource(query); } return statements; } catch (SqlParseException) { throw; } catch (Exception ex) { throw new SqlParseException("The input string cannot be parsed into SQL Statements", ex); } }