public RDFAskQueryResult ApplyToGraph(RDFGraph graph)
{
if (graph != null) {
this.PatternGroupResultTables.Clear();
this.PatternResultTables.Clear();
RDFAskQueryResult askResult = new RDFAskQueryResult();
if (this.PatternGroups.Any()) {
//Iterate the pattern groups of the query
foreach (RDFPatternGroup patternGroup in this.PatternGroups) {
//Step 1: Get the intermediate result tables of the current pattern group
RDFQueryEngine.EvaluatePatterns(this, patternGroup, graph);
//Step 2: Get the result table of the current pattern group
RDFQueryEngine.CombinePatterns(this, patternGroup);
//Step 3: Apply the filters of the current pattern group to its result table
RDFQueryEngine.ApplyFilters(this, patternGroup);
}
//Step 4: Get the result table of the query
DataTable queryResultTable = RDFQueryEngine.CombineTables(this.PatternGroupResultTables.Values.ToList(), false);
//Step 5: Transform the result into a boolean response
askResult.AskResult = (queryResultTable.Rows.Count > 0);
}
return askResult;
}
throw new RDFQueryException("Cannot execute ASK query because given \"graph\" parameter is null.");
}