From: George A. <geo...@gm...> - 2013-04-06 03:46:30
|
Hello Support, This is w.r.t my question on answers.semanticweb.com at " http://answers.semanticweb.com/questions/21871/sparql-subsequent-query-on-retrieved-results-using-dotnetrdf " @Tomasz Pluskiewicz<http://answers.semanticweb.com/users/1788/tomasz-pluskiewicz> : suggested me to add " *Options.AlgebraOptimisation = false;*" before I make the queries; but my doubt is should I addd them before both my queries or only before any one. The problem code is as follows: var graph = (IGraph)store.ExecuteQuery(@" PREFIX sage: < http://www.semanticsage.home.lc/LearningStyles.rdf#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX : < http://www.semanticsage.home.lc/LearningStyles.rdf#> CONSTRUCT { ?MTech :max ?maxScore } WHERE { SELECT ?MTech (MAX(?max) AS ?maxScore) WHERE { SELECT ?MTech ?LessonType (SUM(?hasValue) AS ?max) WHERE { ?MTech sage:attendsLessons ?Lesson. ?Lesson sage:hasLessonType ?LessonType. ?MTech sage:undergoesEvaluation ?Quiz. ?Quiz sage:isForLesson ?Lesson. ?MTech sage:hasQuizMarks ?QuizMarks. ?QuizMarks sage:belongsToQuiz ?Quiz. ?QuizMarks sage:hasValue ?hasValue. ?Lesson sage:inRound '1'^^xsd:int. } GROUP BY ?MTech ?LessonType } GROUP BY ?MTech }"); // here a graph name is given to the result graph graph.BaseUri = new Uri(" http://semanticsage.home.lc/files/LearningStyles.rdf#maxValues"); store.Add(graph, true); Object actualResults = store.ExecuteQuery(@" PREFIX sage: < http://www.semanticsage.home.lc/LearningStyles.rdf#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX : < http://www.semanticsage.home.lc/LearningStyles.rdf#> SELECT ?MTech ?LessonType ?max WHERE { GRAPH < http://semanticsage.home.lc/files/LearningStyles.rdf#maxValues> { ?MTech :max ?max } { SELECT ?MTech ?LessonType (SUM(?hasValue) AS ?Score) WHERE { ?MTech sage:attendsLessons ?Lesson. ?Lesson sage:hasLessonType ?LessonType. ?MTech sage:undergoesEvaluation ?Quiz. ?Quiz sage:isForLesson ?Lesson. ?MTech sage:hasQuizMarks ?QuizMarks. ?QuizMarks sage:belongsToQuiz ?Quiz. ?QuizMarks sage:hasValue ?hasValue. ?Lesson sage:inRound '1'^^xsd:int. } GROUP BY ?MTech ?LessonType ORDER BY ?MTech } FILTER(?Score = ?max) }"); DataTable table = new DataTable(); DataRow row; if (actualResults is SparqlResultSet) { SparqlResultSet rset = (SparqlResultSet)actualResults; foreach (String var in rset.Variables) { table.Columns.Add(new DataColumn(var)); } MessageBox.Show(rset.Count().ToString()); foreach (SparqlResult r in rset) { row = table.NewRow(); foreach (String var in r.Variables) { if (r.HasValue(var) && r[var] != null) { INode n = r[var]; switch (n.NodeType) { case NodeType.Literal: //For literals you only want the lexical value only so need to cast to //literal and access the Value property row[var] = ((ILiteralNode)n).Value; break; case NodeType.Uri: Uri u = ((IUriNode)n).Uri; if (!u.Fragment.Equals(String.Empty)) //u.Fragment is the fragment ID, the #blah part of the URI { row[var] = u.Fragment.Substring(1); } else { row[var] = u.AbsoluteUri; } break; default: //For any other node we just want the string form so //ToString() is sufficient row[var] = n.ToString(); break; } } } table.Rows.Add(row); } } DataSet ds = new DataSet(); ds.Tables.Add(table); dataGridRound1LS.DataSource = ds.Tables[0]; The query is perfect but it returns no values on my system, whereas it is working perfectly fine for@Tomasz Pluskiewicz<http://answers.semanticweb.com/users/1788/tomasz-pluskiewicz> . Could someone provide me with a solution. My RDF is available at: http://semanticsage.home.lc/files/LearningStyles.rdf The project containing only the problematic code is available at: http://semanticsage.home.lc/files/MaxValueCalculationCheck.rar As of now the project contains dotNetRDF version 0.9 (the one available from NuGet). I have even downloaded the latest nightly build and checked on it, but still the same error. -- Regards,* George Abraham* M.Tech CSE, VIT University *m:* +91-8870456778 | *e:* geo...@gm..., geo...@vi... <geo...@vi...> |