Show / Hide Table of Contents

Class VirtuosoConnectorBase

The base class containing common code for VirtuosoConnector and VirtuosoManager.

Inheritance
System.Object
BaseAsyncSafeConnector
VirtuosoConnectorBase
VirtuosoConnector
VirtuosoManager
Implements
IAsyncStorageProvider
IUpdateableStorage
IQueryableStorage
IStorageProvider
IStorageCapabilities
System.IDisposable
Inherited Members
BaseAsyncSafeConnector.ParentServer
BaseAsyncSafeConnector.AsyncParentServer
BaseAsyncSafeConnector.UriFactory
BaseAsyncSafeConnector.LoadGraph(IGraph, Uri)
BaseAsyncSafeConnector.LoadGraph(IGraph, String)
BaseAsyncSafeConnector.LoadGraph(IRdfHandler, Uri)
BaseAsyncSafeConnector.LoadGraph(IRdfHandler, String)
BaseAsyncSafeConnector.SaveGraph(IGraph)
BaseAsyncSafeConnector.UpdateGraph(IRefNode, IEnumerable<Triple>, IEnumerable<Triple>)
BaseAsyncSafeConnector.UpdateGraph(Uri, IEnumerable<Triple>, IEnumerable<Triple>)
BaseAsyncSafeConnector.UpdateGraph(String, IEnumerable<Triple>, IEnumerable<Triple>)
BaseAsyncSafeConnector.DeleteGraph(Uri)
BaseAsyncSafeConnector.Dispose()
BaseAsyncSafeConnector.LoadGraph(IGraph, Uri, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.LoadGraph(IGraph, String, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.LoadGraph(IRdfHandler, Uri, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.LoadGraph(IRdfHandler, String, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.LoadGraphAsync(IGraph, String, CancellationToken)
BaseAsyncSafeConnector.LoadGraphAsync(IRdfHandler, String, CancellationToken)
BaseAsyncSafeConnector.SaveGraph(IGraph, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.SaveGraphAsync(IGraph, CancellationToken)
BaseAsyncSafeConnector.UpdateGraph(Uri, IEnumerable<Triple>, IEnumerable<Triple>, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.UpdateGraph(String, IEnumerable<Triple>, IEnumerable<Triple>, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.UpdateGraphAsync(String, IEnumerable<Triple>, IEnumerable<Triple>, CancellationToken)
BaseAsyncSafeConnector.DeleteGraph(Uri, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.DeleteGraph(String, AsyncStorageCallback, Object)
BaseAsyncSafeConnector.DeleteGraphAsync(String, CancellationToken)
BaseAsyncSafeConnector.ListGraphs(AsyncStorageCallback, Object)
BaseAsyncSafeConnector.ListGraphsAsync(CancellationToken)
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 Source

VirtuosoConnectorBase(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.

| Improve this Doc View Source

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
| Improve this Doc View Source

_db

The currently established connection to the server.

Declaration
protected readonly VirtuosoConnection _db
Field Value
Type Description
VirtuosoConnection
| Improve this Doc View Source

_dbName

The name of the Virtuoso database to connect to.

Declaration
protected readonly string _dbName
Field Value
Type Description
System.String
| Improve this Doc View Source

_dbPassword

The password to use for the connection.

Declaration
protected readonly string _dbPassword
Field Value
Type Description
System.String
| Improve this Doc View Source

_dbPort

The server port to connect to.

Declaration
protected readonly int _dbPort
Field Value
Type Description
System.Int32
| Improve this Doc View Source

_dbServer

The server to connect to.

Declaration
protected readonly string _dbServer
Field Value
Type Description
System.String
| Improve this Doc View Source

_dbTimeout

The command timeout for the connection (in seconds).

Declaration
protected readonly int _dbTimeout
Field Value
Type Description
System.Int32
| Improve this Doc View Source

_dbTransaction

The currently in-flight transaction being used by the connector.

Declaration
protected VirtuosoTransaction _dbTransaction
Field Value
Type Description
VirtuosoTransaction
| Improve this Doc View Source

_dbUser

The user name to use for the connection.

Declaration
protected readonly string _dbUser
Field Value
Type Description
System.String
| Improve this Doc View Source

_formatter

The formatter to use when writing triples to send to the Virtuoso server.

Declaration
protected readonly ITripleFormatter _formatter
Field Value
Type Description
ITripleFormatter
| Improve this Doc View Source

_keepOpen

Indicates whether the Database Connection is currently being kept open.

Declaration
protected bool _keepOpen
Field Value
Type Description
System.Boolean
| Improve this Doc View Source

DefaultDB

Default Database for Virtuoso Server Quad Store.

Declaration
public const string DefaultDB = null
Field Value
Type Description
System.String
| Improve this Doc View Source

DefaultPort

Default Port for Virtuoso Servers.

Declaration
public const int DefaultPort = null
Field Value
Type Description
System.Int32

Properties

| Improve this Doc View Source

DeleteSupported

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
BaseAsyncSafeConnector.DeleteSupported
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.

| Improve this Doc View Source

HasActiveTransaction

Gets whether there is any active transaction on the Virtuoso database.

Declaration
public bool HasActiveTransaction { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

HasOpenConnection

Gets whether there is an active connection to the Virtuoso database.

Declaration
public bool HasOpenConnection { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IOBehaviour

Gets the IO Behaviour of the store.

Declaration
public override IOBehaviour IOBehaviour { get; }
Property Value
Type Description
IOBehaviour
Overrides
BaseAsyncSafeConnector.IOBehaviour
| Improve this Doc View Source

IsReadOnly

Gets whether the Store is read only.

Declaration
public override bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean
Overrides
BaseAsyncSafeConnector.IsReadOnly
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.

| Improve this Doc View Source

IsReady

Indicates whether the Store is ready to accept requests.

Declaration
public override bool IsReady { get; }
Property Value
Type Description
System.Boolean
Overrides
BaseAsyncSafeConnector.IsReady
| Improve this Doc View Source

ListGraphsSupported

Gets whether the Store supports listing graphs via the ListGraphs() method.

Declaration
public override bool ListGraphsSupported { get; }
Property Value
Type Description
System.Boolean
Overrides
BaseAsyncSafeConnector.ListGraphsSupported
| Improve this Doc View Source

UpdateSupported

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
BaseAsyncSafeConnector.UpdateSupported
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 Source

Close(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.

| Improve this Doc View Source

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
BaseAsyncSafeConnector.DeleteGraph(String)
| Improve this Doc View Source

DeleteGraph(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
BaseAsyncSafeConnector.ListGraphNames()
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.

| Improve this Doc View Source

ListGraphs()

Lists the Graphs in the store.

Declaration
public override IEnumerable<Uri> ListGraphs()
Returns
Type Description
IEnumerable<Uri>
Overrides
BaseAsyncSafeConnector.ListGraphs()
| Improve this Doc View Source

LoadGraph(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.

| Improve this Doc View Source

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

SerializeConfiguration(ConfigurationSerializationContext)

Serializes the connection's configuration.

Declaration
public void SerializeConfiguration(ConfigurationSerializationContext context)
Parameters
Type Name Description
ConfigurationSerializationContext context

Configuration Serialization Context.

| Improve this Doc View Source

UnmarshalName(IRefNode)

Declaration
protected string UnmarshalName(IRefNode name)
Parameters
Type Name Description
IRefNode name
Returns
Type Description
System.String
| Improve this Doc View Source

UnmarshalUri(Uri)

Declaration
protected string UnmarshalUri(Uri u)
Parameters
Type Name Description
Uri u
Returns
Type Description
System.String
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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).

| Improve this Doc View Source

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

Implements

IAsyncStorageProvider
IUpdateableStorage
IQueryableStorage
IStorageProvider
IStorageCapabilities
System.IDisposable

Extension Methods

Extensions.AsEnumerable<T>(T)
Extensions.ToSafeString(Object)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX