コード例 #1
0
 /// <summary>
 /// Updates the view by making the SPARQL Query in-memory over the relevant Triple Store.
 /// </summary>
 protected override void UpdateViewInternal()
 {
     try
     {
         var processor = new LeviathanQueryProcessor((IInMemoryQueryableStore)_store);
         var results   = processor.ProcessQuery(_q);
         if (results is IGraph g)
         {
             // Note that we replace the existing triple collection with an entirely new one as otherwise nasty race conditions can happen
             // This does mean that while the update is occurring the user may be viewing a stale graph
             DetachEventHandlers(_triples);
             TreeIndexedTripleCollection triples = new TreeIndexedTripleCollection();
             foreach (Triple t in g.Triples)
             {
                 triples.Add(t.CopyTriple(this));
             }
             _triples = triples;
             AttachEventHandlers(_triples);
         }
         else
         {
             // Note that we replace the existing triple collection with an entirely new one as otherwise nasty race conditions can happen
             // This does mean that while the update is occurring the user may be viewing a stale graph
             DetachEventHandlers(_triples);
             _triples = ((SparqlResultSet)results).ToTripleCollection(this);
             AttachEventHandlers(_triples);
         }
         LastError = null;
         RaiseGraphChanged();
     }
     catch (RdfQueryException queryEx)
     {
         LastError = new RdfQueryException("Unable to Update a SPARQL View as an error occurred in processing the Query - see Inner Exception for details", queryEx);
     }
 }
コード例 #2
0
 /// <summary>
 /// Updates the view by making the query over the Native Store (i.e. the query is handled by the stores SPARQL implementation).
 /// </summary>
 protected override void UpdateViewInternal()
 {
     try
     {
         var results = ((INativelyQueryableStore)_store).ExecuteQuery(_q.ToString());
         if (results is IGraph g)
         {
             DetachEventHandlers(_triples);
             foreach (var t in g.Triples)
             {
                 _triples.Add(t.CopyTriple(this));
             }
             AttachEventHandlers(_triples);
         }
         else
         {
             DetachEventHandlers(_triples);
             _triples = ((SparqlResultSet)results).ToTripleCollection(this);
             AttachEventHandlers(_triples);
         }
         LastError = null;
         RaiseGraphChanged();
     }
     catch (RdfQueryException queryEx)
     {
         LastError = new RdfQueryException("Unable to Update a SPARQL View as an error occurred in processing the Query - see Inner Exception for details", queryEx);
     }
 }