virtuoso

ADO.NET Provider for OpenLink Virtuoso for .NET 8.0?


In old projects I am using the OpenLink.Data.Virtuoso provider to access data stored in a Virtuoso server. I now want to upgrade these projects to .NET 8.0 - but I cannot find any update to the provider I used before (it's from 2015).

How can I access (read/write) data to a Virtuoso server with .NET 8.0?

Thanks in advance,
Frank

I searched the web but all I found was the old provider for ADO.NET 3.5


Solution

  • You need to install these packages first for net 8 to communicate with virtuoso

    dotnet add package OpenLink.Data.Virtuoso
    
    dotnet add package VirtuosoProvider
    

    after that you can use them like this

    using System.Data;
    using OpenLink.Data.Virtuoso;
    
    var connectionString = "Server=localhost;Port=1111;User ID=dba;Password=dba;Database=Virtuoso";
    
    using (var conn = new VirtuosoConnection(connectionString))
    {
        conn.Open();
        VirtuosoCommand cmd = conn.CreateCommand();
        cmd.CommandText = "SPARQL SELECT * WHERE { ?s ?p ?o } LIMIT 10";
    
        using (VirtuosoDataReader reader = cmd.ExecuteReader())
        {
            while (reader.Read())
            {
                Console.WriteLine(reader[0] + " " + reader[1] + " " + reader[2]);
            }
        }
    }