Class VirtuosoConnectorBase
The base class containing common code for VirtuosoConnector and VirtuosoManager.
Inheritance
Implements
Inherited Members
Namespace: VDS.RDF.Storage
Assembly: dotNetRdf.Data.Virtuoso.dll
Syntax
public abstract class VirtuosoConnectorBase : BaseAsyncSafeConnector, IAsyncStorageProvider, IUpdateableStorage, IQueryableStorage, IStorageProvider, IStorageCapabilities
Remarks
This class cannot be instantiated. Instantiate one of the derived classes instead.
Constructors
| Improve this Doc View SourceVirtuosoConnectorBase(String)
Creates a Manager for a Virtuoso Native Quad Store.
Declaration
protected VirtuosoConnectorBase(string connectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | connectionString | Connection String. |
Remarks
Allows the end user to specify a customized connection string.
VirtuosoConnectorBase(String, Int32, String, String, String, Int32)
Creates a Manager for a Virtuoso Native Quad Store.
Declaration
protected VirtuosoConnectorBase(string server, int port, string db, string user, string password, int timeout = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | server | Server. |
System.Int32 | port | Port. |
System.String | db | Database Name. |
System.String | user | Username. |
System.String | password | Password. |
System.Int32 | timeout | Connection Timeout in Seconds. |
Remarks
Timeouts less than equal to zero are ignored and treated as using the default timeout which is dictated by the underlying Virtuoso ADO.Net provider.
Fields
| Improve this Doc View Source_customConnectionString
Indicates whether the connection was established using a user-provided custom connection string.
Declaration
protected readonly bool _customConnectionString
Field Value
Type | Description |
---|---|
System.Boolean |
_db
The currently established connection to the server.
Declaration
protected readonly VirtuosoConnection _db
Field Value
Type | Description |
---|---|
VirtuosoConnection |
_dbName
The name of the Virtuoso database to connect to.
Declaration
protected readonly string _dbName
Field Value
Type | Description |
---|---|
System.String |
_dbPassword
The password to use for the connection.
Declaration
protected readonly string _dbPassword
Field Value
Type | Description |
---|---|
System.String |
_dbPort
The server port to connect to.
Declaration
protected readonly int _dbPort
Field Value
Type | Description |
---|---|
System.Int32 |
_dbServer
The server to connect to.
Declaration
protected readonly string _dbServer
Field Value
Type | Description |
---|---|
System.String |
_dbTimeout
The command timeout for the connection (in seconds).
Declaration
protected readonly int _dbTimeout
Field Value
Type | Description |
---|---|
System.Int32 |
_dbTransaction
The currently in-flight transaction being used by the connector.
Declaration
protected VirtuosoTransaction _dbTransaction
Field Value
Type | Description |
---|---|
VirtuosoTransaction |
_dbUser
The user name to use for the connection.
Declaration
protected readonly string _dbUser
Field Value
Type | Description |
---|---|
System.String |
_formatter
The formatter to use when writing triples to send to the Virtuoso server.
Declaration
protected readonly ITripleFormatter _formatter
Field Value
Type | Description |
---|---|
ITripleFormatter |
_keepOpen
Indicates whether the Database Connection is currently being kept open.
Declaration
protected bool _keepOpen
Field Value
Type | Description |
---|---|
System.Boolean |
DefaultDB
Default Database for Virtuoso Server Quad Store.
Declaration
public const string DefaultDB = null
Field Value
Type | Description |
---|---|
System.String |
DefaultPort
Default Port for Virtuoso Servers.
Declaration
public const int DefaultPort = null
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
| Improve this Doc View SourceDeleteSupported
Gets whether the Store supports Graph deletion via the DeleteGraph(Uri) method.
Declaration
public override bool DeleteSupported { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
Remarks
Some Stores do not support the deletion of Graphs and may as designated in the interface definition throw a System.NotSupportedException if the DeleteGraph() method is called. This property allows for calling code to check in advance whether Deletion of Graphs is supported.
HasActiveTransaction
Gets whether there is any active transaction on the Virtuoso database.
Declaration
public bool HasActiveTransaction { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
HasOpenConnection
Gets whether there is an active connection to the Virtuoso database.
Declaration
public bool HasOpenConnection { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IOBehaviour
Gets the IO Behaviour of the store.
Declaration
public override IOBehaviour IOBehaviour { get; }
Property Value
Type | Description |
---|---|
IOBehaviour |
Overrides
| Improve this Doc View SourceIsReadOnly
Gets whether the Store is read only.
Declaration
public override bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
Remarks
Any Manager which indicates it is read-only should also return false for the UpdateSupported property and should throw a RdfStorageException if the SaveGraph() or UpdateGraph() methods are called.
IsReady
Indicates whether the Store is ready to accept requests.
Declaration
public override bool IsReady { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
| Improve this Doc View SourceListGraphsSupported
Gets whether the Store supports listing graphs via the ListGraphs() method.
Declaration
public override bool ListGraphsSupported { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
| Improve this Doc View SourceUpdateSupported
Gets whether the Store supports Triple level updates via the UpdateGraph(Uri, IEnumerable<Triple>, IEnumerable<Triple>) method.
Declaration
public override bool UpdateSupported { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
Remarks
Some Stores do not support updates at the Triple level and may as designated in the interface defintion throw a System.NotSupportedException if the UpdateGraph() method is called. This property allows for calling code to check in advance whether Updates are supported.
Methods
| Improve this Doc View SourceClose(Boolean, Boolean)
Closes the Connection to the Database.
Declaration
protected void Close(bool forceClose, bool rollbackTrans = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | forceClose | Indicates that the connection should be closed even if keepOpen was specified when the Connection was opened. |
System.Boolean | rollbackTrans | Indicates that the Transaction should be rolled back because something has gone wrong. |
DeleteGraph(String)
Deletes a Graph from the store.
Declaration
public override void DeleteGraph(string graphUri)
Parameters
Type | Name | Description |
---|---|---|
System.String | graphUri | URI of the Graph to delete. |
Overrides
| Improve this Doc View SourceDeleteGraph(Uri)
Deletes a Graph from the Virtuoso store.
Declaration
public override void DeleteGraph(Uri graphUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | graphUri | URI of the Graph to delete. |
ExecuteNonQuery(String)
Executes a Non-Query SQL Command against the database.
Declaration
protected void ExecuteNonQuery(string sqlCmd)
Parameters
Type | Name | Description |
---|---|---|
System.String | sqlCmd | SQL Command. |
ListGraphNames()
Gets an enumeration of the names of the graphs in the store.
Declaration
public override IEnumerable<string> ListGraphNames()
Returns
Type | Description |
---|---|
IEnumerable<System.String> |
Overrides
Remarks
Implementations should implement this method only if they need to provide a custom way of listing Graphs. If the Store for which you are providing a manager can efficiently return the Graphs using a SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } } query then there should be no need to implement this function.
ListGraphs()
Lists the Graphs in the store.
Declaration
public override IEnumerable<Uri> ListGraphs()
Returns
Type | Description |
---|---|
IEnumerable<Uri> |
Overrides
| Improve this Doc View SourceLoadGraph(IRdfHandler, Uri)
Loads a Graph from the Quad Store.
Declaration
public override void LoadGraph(IRdfHandler handler, Uri graphUri)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler. |
Uri | graphUri | URI of the Graph to Load. |
LoadNode(INodeFactory, Object)
Decodes an Object into an appropriate Node.
Declaration
protected INode LoadNode(INodeFactory factory, object n)
Parameters
Type | Name | Description |
---|---|---|
INodeFactory | factory | Node Factory to use to create Node. |
System.Object | n | Object to convert. |
Returns
Type | Description |
---|---|
INode |
Open(Boolean, IsolationLevel)
Start a transaction if one is not already in progress.
Declaration
protected bool Open(bool keepOpen = false, IsolationLevel level = null)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | keepOpen | Whether to hold this connection open until a close is forced. |
IsolationLevel | level | The isolation level of the new transaction. |
Returns
Type | Description |
---|---|
System.Boolean | True if a new transaction was started, false if an existing transaction was reused. |
Query(String)
Executes a SPARQL Query on the native Quad Store.
Declaration
public object Query(string sparqlQuery)
Parameters
Type | Name | Description |
---|---|---|
System.String | sparqlQuery | SPARQL Query to execute. |
Returns
Type | Description |
---|---|
System.Object |
Remarks
This method will first attempt to parse the query into a SparqlQuery object. If this succeeds then the Query Type can be used to determine how to handle the response.
If the parsing fails then the query will be executed anyway using Virtuoso's SPASQL (SPARQL + SQL) syntax. Parsing can fail because Virtuoso supports various SPARQL extensions which the library does not support. These include things like aggregate functions but also SPARUL updates (the non-standard precusor to SPARQL 1.1 Update).
If you use an aggregate query which has an Integer, Decimal or Double type result then you will receive a SparqlResultSet containing a single SparqlResult which has contains a binding for a variable named Result which contains a LiteralNode typed to the appropriate datatype.
Exceptions
Type | Condition |
---|---|
RdfQueryException | Thrown if an error occurs in making the query. |
Query(IRdfHandler, ISparqlResultsHandler, String)
Executes a SPARQL Query on the native Quad Store processing the results with an appropriate handler from those provided.
Declaration
public void Query(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, string sparqlQuery)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | rdfHandler | RDF Handler. |
ISparqlResultsHandler | resultsHandler | Results Handler. |
System.String | sparqlQuery | SPARQL Query to execute. |
Remarks
This method will first attempt to parse the query into a SparqlQuery object. If this succeeds then the Query Type can be used to determine how to handle the response.
If the parsing fails then the query will be executed anyway using Virtuoso's SPASQL (SPARQL + SQL) syntax. Parsing can fail because Virtuoso supports various SPARQL non-standardised extensions which the library does not support. These include things like aggregate functions but also SPARUL updates (the non-standard precusor to SPARQL 1.1 Update).
If you use an aggregate query which has an Integer, Decimal or Double type result then you will receive a SparqlResultSet containing a single SparqlResult which has contains a binding for a variable named Result which contains a LiteralNode typed to the appropriate datatype.
Exceptions
Type | Condition |
---|---|
RdfQueryException | Thrown if an error occurs in making the query. |
SaveGraphInternal(IGraph)
Creates and executes the Virtuoso commands required to update a graph.
Declaration
protected void SaveGraphInternal(IGraph g)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | The new graph state. |
Remarks
The Name property of g
is used to name the graph on the Virtuoso server that is replaced/created by this operation.
SerializeConfiguration(ConfigurationSerializationContext)
Serializes the connection's configuration.
Declaration
public void SerializeConfiguration(ConfigurationSerializationContext context)
Parameters
Type | Name | Description |
---|---|---|
ConfigurationSerializationContext | context | Configuration Serialization Context. |
UnmarshalName(IRefNode)
Declaration
protected string UnmarshalName(IRefNode name)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | name |
Returns
Type | Description |
---|---|
System.String |
UnmarshalUri(Uri)
Declaration
protected string UnmarshalUri(Uri u)
Parameters
Type | Name | Description |
---|---|---|
Uri | u |
Returns
Type | Description |
---|---|
System.String |
Update(String)
Processes a SPARQL Update command against the underlying Store.
Declaration
public abstract void Update(string sparqlUpdate)
Parameters
Type | Name | Description |
---|---|---|
System.String | sparqlUpdate | SPARQL Update. |
UpdateGraph(String, IEnumerable<Triple>, IEnumerable<Triple>)
Updates a Graph in the Quad Store.
Declaration
public override void UpdateGraph(string graphUri, IEnumerable<Triple> additions, IEnumerable<Triple> removals)
Parameters
Type | Name | Description |
---|---|---|
System.String | graphUri | Graph Uri of the Graph to update. |
IEnumerable<Triple> | additions | Triples to be added. |
IEnumerable<Triple> | removals | Triples to be removed. |
UpdateGraph(Uri, IEnumerable<Triple>, IEnumerable<Triple>)
Updates a Graph in the Quad Store.
Declaration
public override void UpdateGraph(Uri graphUri, IEnumerable<Triple> additions, IEnumerable<Triple> removals)
Parameters
Type | Name | Description |
---|---|---|
Uri | graphUri | Graph Uri of the Graph to update. |
IEnumerable<Triple> | additions | Triples to be added. |
IEnumerable<Triple> | removals | Triples to be removed. |
Remarks
In the case of inserts where blank nodes are present the data will be inserted but new blank nodes will be created. You cannot insert data that refers to existing blank nodes via this method, consider using a INSERT WHERE style SPARQL Update instead.
Note that Blank Nodes cannot always be deleted successfully, if you have retrieved the triples you are now trying to delete from Virtuoso and they contain blank nodes then this will likely work as expected. Otherwise deletetions of Blank Nodes cannot be guaranteed.
If the Graph being modified is relatively small it may be safer to load the graph into memory, makes the modifications there and then persist the graph back to the store (which overwrites the previous version of the graph).
UpdateGraph(IRefNode, IEnumerable<Triple>, IEnumerable<Triple>)
Declaration
public override void UpdateGraph(IRefNode graphName, IEnumerable<Triple> additions, IEnumerable<Triple> removals)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | graphName | |
IEnumerable<Triple> | additions | |
IEnumerable<Triple> | removals |